| @@ 25-53 (lines=29) @@ | ||
| 22 | * |
|
| 23 | * @return string |
|
| 24 | */ |
|
| 25 | protected function renderHtmlErrorMessage(\Exception $exception) |
|
| 26 | { |
|
| 27 | $title = 'Slim Application Error'; |
|
| 28 | ||
| 29 | if ($this->displayErrorDetails) { |
|
| 30 | $html = '<p>The application could not run because of the following error:</p>'; |
|
| 31 | $html .= '<h2>Details</h2>'; |
|
| 32 | $html .= $this->renderHtmlException($exception); |
|
| 33 | ||
| 34 | while ($exception = $exception->getPrevious()) { |
|
| 35 | $html .= '<h2>Previous exception</h2>'; |
|
| 36 | $html .= $this->renderHtmlExceptionOrError($exception); |
|
| 37 | } |
|
| 38 | } else { |
|
| 39 | $html = '<p>A website error has occurred. Sorry for the temporary inconvenience.</p>'; |
|
| 40 | } |
|
| 41 | ||
| 42 | $output = sprintf( |
|
| 43 | "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" . |
|
| 44 | "<title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana," . |
|
| 45 | "sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{" . |
|
| 46 | "display:inline-block;width:65px;}</style></head><body><h1>%s</h1>%s</body></html>", |
|
| 47 | $title, |
|
| 48 | $title, |
|
| 49 | $html |
|
| 50 | ); |
|
| 51 | ||
| 52 | return $output; |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * Render exception as HTML. |
|
| @@ 17-45 (lines=29) @@ | ||
| 14 | return $this->renderHtmlPhpErrorMessage($args[0]); |
|
| 15 | } |
|
| 16 | ||
| 17 | protected function renderHtmlPhpErrorMessage(\Throwable $error) |
|
| 18 | { |
|
| 19 | $title = 'Slim Application Error'; |
|
| 20 | ||
| 21 | if ($this->displayErrorDetails) { |
|
| 22 | $html = '<p>The application could not run because of the following error:</p>'; |
|
| 23 | $html .= '<h2>Details</h2>'; |
|
| 24 | $html .= $this->renderHtmlError($error); |
|
| 25 | ||
| 26 | while ($error = $error->getPrevious()) { |
|
| 27 | $html .= '<h2>Previous error</h2>'; |
|
| 28 | $html .= $this->renderHtmlError($error); |
|
| 29 | } |
|
| 30 | } else { |
|
| 31 | $html = '<p>A website error has occurred. Sorry for the temporary inconvenience.</p>'; |
|
| 32 | } |
|
| 33 | ||
| 34 | $output = sprintf( |
|
| 35 | "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" . |
|
| 36 | "<title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana," . |
|
| 37 | "sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{" . |
|
| 38 | "display:inline-block;width:65px;}</style></head><body><h1>%s</h1>%s</body></html>", |
|
| 39 | $title, |
|
| 40 | $title, |
|
| 41 | $html |
|
| 42 | ); |
|
| 43 | ||
| 44 | return $output; |
|
| 45 | } |
|
| 46 | ||
| 47 | /** |
|
| 48 | * Render error as HTML. |
|