function exceptionHandler(Exception $exception) { profilerStop(); Log::exception($exception); if ($exception instanceof HttpException) { $response = $exception->toResponse(); $response->send(); return; } sendHttpStatus(500); header('content-type: application/json'); echo json_encode(['error_code' => 500, 'error_msg' => 'Server down, please check log!']); }
/** * 普通异常回调方法 * @param $e 异常 */ public static function appException($e) { $error = array(); $error['message'] = $e->getMessage(); $trace = $e->getTrace(); if ('E' == $trace[0]['function']) { $error['file'] = $trace[0]['file']; $error['line'] = $trace[0]['line']; } else { $error['file'] = $e->getFile(); $error['line'] = $e->getLine(); } $error['trace'] = $e->getTraceAsString(); sendHttpStatus(); self::showError($error); }