blessing-skin-server/app/Exceptions/PrettyPageException.php

30 lines
671 B
PHP
Raw Normal View History

<?php
namespace App\Exceptions;
class PrettyPageException extends \Exception
{
2016-09-04 17:05:30 +08:00
/**
2018-02-16 17:31:04 +08:00
* Custom error handler.
2016-09-04 17:05:30 +08:00
*
2018-02-16 17:31:04 +08:00
* @param string $message
* @param int $code
* @param bool $render Whether to show a error page.
* @return void
2016-09-04 17:05:30 +08:00
*/
2016-09-30 23:21:04 +08:00
public function __construct($message = "Error occured.", $code = -1, $render = false)
2016-09-04 17:05:30 +08:00
{
parent::__construct($message, $code);
2016-09-30 23:21:04 +08:00
if ($render) {
$this->showErrorPage()->send();
exit;
}
2016-09-04 17:05:30 +08:00
}
2016-09-30 23:21:04 +08:00
public function showErrorPage()
2016-09-04 17:05:30 +08:00
{
2016-09-30 23:21:04 +08:00
return response()->view('errors.pretty', ['code' => $this->code, 'message' => $this->message]);
2016-09-04 17:05:30 +08:00
}
}