Can I instantiate an exception without throwing it?
php, php-5.4
Solution
Yes, an exception is just like any other object.
Problem
I am using a SaaS error and exception logging service called Rollbar. In my code, I have a `Rollbar` static object that I can use to report exceptions to the service. For example: ``` try { ... throw new SomeException(); ... } catch (SomeException $e) { Rollbar::report_exception($e); } ``` My question is: Can I instantiate an exception without throwing it, as if it were any other normal object, and are there any caveats? I would like to do things like this: ``` if($api_response_ok) { // Do some stuff ... } else { Rollbar::report_exception(new ApiException($api_error_msg)); } // Script execution continues... ```