Custom Error Handling in WordPress Plugins

Solution:

In WordPress, you would use the WP_Error class to handle errors.

There are a set of constants that will determine if errors are reported, displayed or logged, that you would usually define on the wp-config.php:

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);
define('SAVEQUERIES', true);

Of course, when developing, you should have WP_DEBUG as true, and set it to false on a production enviroment.

Check the Developer and Debug Bar plugins, and the WordPress Error Handling series of articles for more info