Example #1
0
 public static function kill($code, $error, $file, $line)
 {
     $app = \Rebond\App::instance();
     $redirect = (int) Session::get('redirect');
     if ($redirect > 5) {
         $app->setStep(\Rebond\Config::STEP_REDIRECT);
     } else {
         Session::set('redirect', $redirect + 1);
     }
     $logId = Log::log($code, $error, $file, $line);
     $json = [];
     $json['result'] = ResultType::ERROR;
     if ($app->step() != \Rebond\Config::STEP_RUNNING) {
         if ($app->ajax()) {
             $json['message'] = Lang::locale('configurationError');
             echo json_encode($json);
             exit;
         } else {
             $controller = new \Rebond\Controller\Admin\Error($app);
             echo $controller->config();
             session_write_close();
             exit;
         }
     } else {
         // update log level if user isDev
         $app->user();
         if ($app->logLevel() == 0) {
             if ($app->ajax()) {
                 $json['message'] = Lang::lang('serviceNotAvailable') . ': ' . $error . ' [<a href="http://' . \Rebond\Config::getPath('adminUrl') . '/tools/log" target="_blank">' . Lang::lang('logsView') . '</a>]';
                 echo json_encode($json, JSON_UNESCAPED_SLASHES);
                 exit;
             } else {
                 if (in_array($code, [self::PAGE_NOT_FOUND, self::ADMIN_PAGE_NOT_FOUND])) {
                     header('Location: /error/generic?404=' . $error);
                 } else {
                     header('Location: /error/detail?id=' . $logId);
                 }
                 session_write_close();
                 exit;
             }
         } else {
             if ($app->ajax()) {
                 $json['message'] = Lang::lang('errorUnknown');
                 echo json_encode($json);
                 exit;
             } else {
                 if (in_array($code, [self::PAGE_NOT_FOUND, self::ADMIN_PAGE_NOT_FOUND])) {
                     header('Location: /error/generic?404=' . $error);
                 } else {
                     header('Location: /error/generic');
                 }
                 session_write_close();
                 exit;
             }
         }
     }
 }