/** * Handles uncaught exceptions that occur in the script * @param \Exception $error */ public static function ExceptionHandler(\Exception $error) { /** * Register error * Does not register error if it is the same as last */ $last = end(self::$errors); if (!is_null($last) && ($last['file'] != $error->getFile() && $last['line'] != $error->getLine())) { self::RegisterError($error->getCode(), $error->getMessage(), $error->getFile(), $error->getLine(), $error->getTrace()); } /** * Generate error report */ $report = ['exception' => get_class($error), 'type' => $error->getCode(), 'message' => $error->getMessage(), 'file' => $error->getFile(), 'line' => $error->getLine(), 'trace' => $error->getTrace()]; /** * Write log file */ try { $log = new Storage\File('Logs/' . Misc\Debug::ErrorTypeToString($error->getCode()) . '-' . time() . '.php.ser'); $log->write(serialize($report)); $log->save(); } catch (\Exception $e) { } /** * Display error */ self::$displayData = [$error, $report]; Web::Abort(500); }