+ $error = error_get_last();
+ if ($error !== null && $error['type'] === E_ERROR) {
+ exception_handler_json(new Exception($error['message'], 500));
+ }
+}
+
+
+function set_exception_handler_by_format($sFormat = null)
+{
+ // Multiple calls to register_shutdown_function will cause multiple callbacks
+ // to be executed, we only want the last executed. Thus we don't want to register
+ // one by default without an explicit $sFormat set.
+
+ if (!isset($sFormat)) {
+ set_exception_handler('exception_handler_html');
+ } elseif ($sFormat == 'html') {