我正在使用名为Rollbar的SaaS错误和异常日志记录服务.在我的代码中,我有一个Rollbar静态对象,我可以用它来报告服务的异常.
例如:
try {
...
throw new SomeException();
...
} catch (SomeException $e) {
Rollbar::report_exception($e);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:我可以在不抛出异常的情况下实例化异常,就像它是任何其他普通对象一样,是否有任何警告?
我想做这样的事情:
if($api_response_ok) {
// Do some stuff
...
} else {
Rollbar::report_exception(new ApiException($api_error_msg));
}
// Script execution continues...
Run Code Online (Sandbox Code Playgroud)