is('favicon.ico')) { $sResponse->send($sRequest->isNotFound(), 200); } else { Snowflake::app()->getRouter()->dispatch(); } } catch (Error | \Throwable $exception) { $this->sendErrorMessage($sResponse ?? null, $exception, $response); } } /** * @throws \Snowflake\Exception\ComponentException */ public function onDefer() { fire(Event::EVENT_AFTER_REQUEST); } /** * @param $response * @throws Exception */ public static function shutdown($response) { $error = error_get_last(); if (!isset($error['type'])) { return; } $types = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR]; if (!in_array($error['type'], $types)) { return; } try { $message = $error['message'] . ':' . microtime(true); if ($response instanceof Response) { $response->status(500); $response->end($message); } } catch (\ErrorException $exception) { $logger = Snowflake::app()->logger; $logger->write($exception->getMessage(), 'shutdown'); } unset($response); } /** * @param $sResponse * @param $exception * @param $response * @return false|int|mixed|string * @throws Exception */ protected function sendErrorMessage($sResponse, $exception, $response) { $params = Snowflake::app()->getLogger()->exception($exception); if (empty($sResponse)) { $sResponse = \response(); $sResponse->response = $response; } return $sResponse->send($params, 200); } }