Error handling a plugin with exceptions

You can also extend expections and then catch only those that you throw.

For example:

function do_add_my_pws_exceptions() {
   class PWS_Exception extends Exception {}
   class PWS_Init_Exception extends PWS_Exception {}
}
add_action('plugins_loaded', 'do_add_my_pws_exceptions');

Of course, you should be certain the user is running at least version 5 of PHP by having your theme of plugin activation do something like the following:

$php_version = phpversion();
if ( version_compare( $php_version, '5.3', '<' ) ) {
    # deactivate your plugin or abort installing your theme and tell the user why
}

Anywise, once that is done, you can then do things like:

try {
   # whatever you are doing
   throw new PWS_Exception("This is my exception", 10001);
} catch ( PWS_Exception $e ) {
   # Your custom handling
}

Any exceptions not thrown by you will not be caught.