/** * Retruns a generic error page. * * @access protected * @param boolean $returnAsJson Should we return JSON? * @return string */ protected function getGenericError($returnAsJson) { $code = $this->exception->getCode(); if ($returnAsJson) { switch ($code) { case 403: $message = 'You don\'t have permission to access the requested resource.'; break; case 404: $message = 'The resource you requested could not be found. It may have been moved or deleted.'; break; case 405: $message = 'The request method that was used is not supported by this resource.'; break; default: $message = 'An error has occurred while processing your request.'; } return json_encode(['message' => $message]); } else { $view = 'error'; if ($this->exception instanceof RequestException) { if ($this->view->exists('mako-error::' . $code)) { $view = $code; } } return $this->view->render('mako-error::' . $view); } }