public function run(Nette\Application\Request $request) { $exception = $request->getParameter('exception'); if ($exception instanceof Nette\Application\BadRequestException) { return new Responses\ForwardResponse($request->setPresenterName('Error4xx')); } $this->logger->log($exception, ILogger::EXCEPTION); return new Responses\CallbackResponse(function () { require __DIR__ . '/templates/Error/500.phtml'; }); }
/** * @param string|array $message * @param string $priority * @return string logged error filename */ public function log($message, $priority = NULL) { $exceptionFile = $this->oldLogger->log($message, $priority); if (in_array($priority, $this->logLevels)) { if (is_array($message)) { $message = implode(' ', $message); } newrelic_notice_error($message); } return $exceptionFile; }
/** * @return Nette\Application\IResponse */ public function run(Nette\Application\Request $request) { $e = $request->getParameter('exception'); if ($e instanceof Nette\Application\BadRequestException) { // $this->logger->log("HTTP code {$e->getCode()}: {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", 'access'); return new Nette\Application\Responses\ForwardResponse($request->setPresenterName('Error4xx')); } $this->logger->log($e, ILogger::EXCEPTION); return new Nette\Application\Responses\CallbackResponse(function () { require __DIR__ . '/templates/Error/500.phtml'; }); }
/** * This method is usually implemented by the more complex UI\Presenter * But since an unhandled exception might have occurred, * it should be processed as simply as possible to avoid any further problems or even another exception. * * @param Nette\Application\Request $request * @return Responses\CallbackResponse|Responses\ForwardResponse */ public function run(Nette\Application\Request $request) { $exception = $request->getParameter('exception'); // if it's a simple BadRequestException, use the more powerful presenter if ($exception instanceof Nette\Application\BadRequestException) { return new Responses\ForwardResponse($request->setPresenterName('Error4xx')); } $this->logger->log($exception, ILogger::EXCEPTION); // the 500 means unhandled exception, which should translate to the simplest page possible return new Responses\CallbackResponse(function () { require __DIR__ . '/templates/Error/500.phtml'; }); }
/** * @param \Exception * @return void */ public function renderDefault($exception) { if ($exception instanceof Nette\Application\BadRequestException) { $code = $exception->getCode(); $this->setView(in_array($code, [403, 404, 405, 410, 500]) ? $code : '4xx'); } else { $this->setView('500'); $this->logger->log($exception, ILogger::EXCEPTION); } if ($this->isAjax()) { $this->payload->error = TRUE; $this->terminate(); } }
/** * @param Exception * @return void */ public function renderDefault($exception) { if ($exception instanceof Nette\Application\BadRequestException) { $code = $exception->getCode(); $this->setView(in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx'); $this->logger->log("HTTP code {$code}: {$exception->getMessage()} in {$exception->getFile()}:{$exception->getLine()}", 'access'); } else { $this->setView('500'); $this->logger->log($exception, ILogger::EXCEPTION); } if ($this->isAjax()) { $this->payload->error = TRUE; $this->terminate(); } }
/** * @return Application\IResponse */ public function run(Application\Request $request) { $e = $request->getParameter('exception'); if ($e instanceof Application\BadRequestException) { $code = $e->getCode(); } else { $code = 500; if ($this->logger) { $this->logger->log($e, ILogger::EXCEPTION); } } return new Application\Responses\CallbackResponse(function () use($code) { require __DIR__ . '/templates/error.phtml'; }); }
/** * @return Application\IResponse */ public function run(Application\Request $request) { $e = $request->parameters['exception']; if ($e instanceof Application\BadRequestException) { $code = $e->getCode(); } else { $code = 500; if ($this->logger) { $this->logger->log($e, ILogger::EXCEPTION); } } ob_start(); require __DIR__ . '/templates/error.phtml'; return new Application\Responses\TextResponse(ob_get_clean()); }
/** * @param string $message * @param string $errorLevel */ public function logMissingTranslation($message) { if ($this->logger instanceof ILogger) { $this->logger->log($message, static::LOGGER_NAMESPACE); } elseif ($this->logger instanceof LoggerInterface) { $this->logger->log(LogLevel::WARNING, sprintf('Missing translation "%s"', $message)); } }
protected function logObject($object, $fileName = NULL) { if (!is_null($this->logDirectory) && !is_null($this->logger) && (!is_array($object) && $object != '' || count($object) > 0)) { @mkdir($this->logger->directory . '/' . $this->logDirectory . '/', 0770); @chmod($this->logger->directory . '/' . $this->logDirectory . '/', 0770); $fileName = is_null($fileName) ? __CLASS__ : str_replace('/', '__', $fileName); $this->logger->log(var_export($object, TRUE), $this->logDirectory . '/' . $fileName); } }
public function create() { try { $this->repository->mapper->getStorageReflection(); } catch (Nextras\Dbal\QueryException $ex) { $this->logger->log($ex, Tracy\ILogger::EXCEPTION); return; } $routes = array_filter(array_map([$this->cache, 'load'], $domains = $this->getDomains())); $domains = array_diff_key($domains, $routes); if ($domains) { $routes = array_merge($routes, array_map([$this, 'getRouteForDomain'], iterator_to_array($this->repository->findById($domains)))); } array_walk($routes, function (array $route) { $this[] = $this->createFileRoute($route); $this[] = $this->createWebRoute($route); }); }
/** * @param Exception * @return void */ public function renderDefault($exception) { if ($exception instanceof Nette\Application\BadRequestException) { $code = $exception->getCode(); // load template 403.latte or 404.latte or ... 4xx.latte $this->setView(in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx'); // log to access.log $this->logger->log("HTTP code {$code}: {$exception->getMessage()} in {$exception->getFile()}:{$exception->getLine()}", 'access'); } else { $this->setView('500'); // load template 500.latte $this->logger->log($exception, ILogger::EXCEPTION); // and log exception } if ($this->isAjax()) { // AJAX request? Note this error in payload. $this->payload->error = TRUE; $this->terminate(); } }
/** * @param Request $request * @return IResponse */ public function run(Request $request) { $e = $request->getParameter('exception'); if ($e instanceof BadRequestException) { $code = $e->getCode(); } else { $code = 500; if ($this->logger) { try { $this->logger->log($e, ILogger::EXCEPTION); } catch (\Exception $e) { // logger may fail as well } } } if (isset(JsonResponse::$messages[$code])) { $message = JsonResponse::$messages[$code]; } else { $message = 'Unknown error'; } return $this->createResponse($message, $code); }
public function actionDefault(Throwable $exception) { if ($exception instanceof Nette\Application\BadRequestException) { $code = $exception->getCode(); if ($this->logger) { $this->logger->log($exception->getMessage()); } } else { $code = Nette\Http\IResponse::S500_INTERNAL_SERVER_ERROR; if ($this->logger) { $this->logger->log($exception, Tracy\ILogger::EXCEPTION); } } if (ob_get_level() && ob_get_length()) { $this->setLayout(FALSE); } $view = $this->getView(); $this->setView($this->code = $this->translator instanceof Symfony\Component\Translation\TranslatorBagInterface && $this->translator->getCatalogue()->has(implode('.', ['error.message', $code, 'title']), 'web') && $this->translator->getCatalogue()->has(implode('.', ['error.message', $code, 'description']), 'web') ? $code : 0); if (!count($this->formatTemplateFiles())) { $this->setView($view); } }