/** * \private * * Show a simple error page. * * \param $http_status_code * The http status code. */ function _show_error_page($http_status_code) { anewt_include('page'); $title = sprintf('%d - %s', $http_status_code, http_status_to_string($http_status_code)); $p = new AnewtPage(); $p->set('show-dublin-core', false); $p->set('title', $title); $p->append(ax_h1($title)); switch ($http_status_code) { case HTTP_STATUS_NOT_FOUND: $p->append(ax_p('The requested resource cannot be found.')); break; case HTTP_STATUS_FORBIDDEN: $p->append(ax_p('Access to the requested resource was denied.')); break; default: /* No explanation (just a title) */ break; } $p->flush(); }
/** * \private * * Show a simple error page. * * \param $exception * The AnewtHTTPException instance */ protected function show_error_page($exception) { assert('$exception instanceof Exception;'); anewt_include('page'); $p = new AnewtPage(); $p->show_dublin_core = false; /* Title */ if ($exception instanceof AnewtHTTPException) { $title = sprintf('%d - %s', $exception->getCode(), http_status_to_string($exception->getCode())); } else { $title = sprintf('%d - %s', HTTP_STATUS_INTERNAL_SERVER_ERROR, http_status_to_string(HTTP_STATUS_INTERNAL_SERVER_ERROR)); } $p->title = $title; $p->append(ax_h1($title)); /* Add default explanation (instead of just a title) for some exceptions. */ $message = $exception->getMessage(); if ($message) { $p->append(ax_p($message)); } else { switch ($exception->getCode()) { case HTTP_STATUS_NOT_FOUND: $p->append(ax_p('The requested resource cannot be found.')); break; case HTTP_STATUS_FORBIDDEN: $p->append(ax_p('Access to the requested resource was denied.')); break; case HTTP_STATUS_INTERNAL_SERVER_ERROR: $p->append(ax_p('An internal server error occurred while processing your request.')); break; default: break; } } /* Backtrace */ $p->append(ax_pre($exception->getTraceAsString())); $p->flush(); }