fix PrettyPageException at setup pages
This commit is contained in:
parent
fa9629e796
commit
5efd875b06
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use App\Exceptions\PrettyPageException;
|
||||||
use App\Http\Middleware\Internationalization;
|
use App\Http\Middleware\Internationalization;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Illuminate\Foundation\Validation\ValidationException;
|
use Illuminate\Foundation\Validation\ValidationException;
|
||||||
|
|
@ -20,7 +21,8 @@ class Handler extends ExceptionHandler
|
||||||
protected $dontReport = [
|
protected $dontReport = [
|
||||||
HttpException::class,
|
HttpException::class,
|
||||||
ModelNotFoundException::class,
|
ModelNotFoundException::class,
|
||||||
ValidationException::class
|
ValidationException::class,
|
||||||
|
PrettyPageException::class
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,10 +52,7 @@ class Handler extends ExceptionHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($e instanceof PrettyPageException && PHP_SAPI != "cli") {
|
if ($e instanceof PrettyPageException && PHP_SAPI != "cli") {
|
||||||
echo \View::make('errors.e')->with('code', $e->getCode())
|
return $e->showErrorPage();
|
||||||
->with('message', $e->getMessage())
|
|
||||||
->render();
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($e instanceof HttpException) {
|
if ($e instanceof HttpException) {
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,18 @@ class PrettyPageException extends \Exception
|
||||||
* @param integer $code
|
* @param integer $code
|
||||||
* @param boolean $render, to show a error page
|
* @param boolean $render, to show a error page
|
||||||
*/
|
*/
|
||||||
function __construct($message = "Error occured.", $code = -1, $render = false)
|
public function __construct($message = "Error occured.", $code = -1, $render = false)
|
||||||
{
|
{
|
||||||
parent::__construct($message, $code);
|
parent::__construct($message, $code);
|
||||||
|
|
||||||
if ($render)
|
if ($render) {
|
||||||
$this->showErrorPage();
|
$this->showErrorPage()->send();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function showErrorPage()
|
public function showErrorPage()
|
||||||
{
|
{
|
||||||
echo \View::make('errors.e')->with('code', $this->code)
|
return response()->view('errors.pretty', ['code' => $this->code, 'message' => $this->message]);
|
||||||
->with('message', $this->message)
|
|
||||||
->render();
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
@extends('errors.general')
|
|
||||||
|
|
||||||
@section('title', trans('errors.general.title'))
|
|
||||||
|
|
||||||
@section('content')
|
|
||||||
<h1>{{ trans('errors.error.title') }}</h1>
|
|
||||||
|
|
||||||
<p>{{ trans('error.exception.code', ['code' => $code]) }}</p>
|
|
||||||
<p>{!! trans('error.exception.message', ['message' => $message]) !!}</p>
|
|
||||||
@endsection
|
|
||||||
10
resources/views/errors/pretty.tpl
Normal file
10
resources/views/errors/pretty.tpl
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
@extends('errors.general')
|
||||||
|
|
||||||
|
@section('title', trans('errors.general.title'))
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<h1>{{ trans('errors.general.title') }}</h1>
|
||||||
|
|
||||||
|
<p>{{ trans('errors.exception.code', ['code' => $code]) }}</p>
|
||||||
|
<p>{!! trans('errors.exception.message', ['msg' => $message]) !!}</p>
|
||||||
|
@endsection
|
||||||
|
|
@ -58,6 +58,7 @@ foreach ($config['aliases'] as $facade => $class) {
|
||||||
(new Illuminate\Filesystem\FilesystemServiceProvider($app))->register();
|
(new Illuminate\Filesystem\FilesystemServiceProvider($app))->register();
|
||||||
(new Illuminate\Session\SessionServiceProvider($app))->register();
|
(new Illuminate\Session\SessionServiceProvider($app))->register();
|
||||||
(new Illuminate\Encryption\EncryptionServiceProvider($app))->register();
|
(new Illuminate\Encryption\EncryptionServiceProvider($app))->register();
|
||||||
|
(new Devitek\Core\Translation\TranslationServiceProvider($app))->register();
|
||||||
|
|
||||||
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* @Author: printempw
|
* @Author: printempw
|
||||||
* @Date: 2016-09-14 16:57:37
|
* @Date: 2016-09-14 16:57:37
|
||||||
* @Last Modified by: printempw
|
* @Last Modified by: printempw
|
||||||
* @Last Modified time: 2016-09-14 19:53:22
|
* @Last Modified time: 2016-09-30 23:18:56
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function check_table_exists() {
|
function check_table_exists() {
|
||||||
|
|
@ -20,14 +20,14 @@ function check_table_exists() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect_to($url, $msg = "") {
|
function redirect_to($url, $msg = "") {
|
||||||
if ($msg !== "") {
|
// if ($msg !== "") {
|
||||||
if (app()->bound('session')) {
|
// if (app()->bound('session')) {
|
||||||
Session::put('msg', $msg);
|
// Session::put('msg', $msg);
|
||||||
Session::save();
|
// Session::save();
|
||||||
} else {
|
// } else {
|
||||||
$_SESSION['msg'] = $msg;
|
$_SESSION['msg'] = $msg;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!headers_sent()) {
|
if (!headers_sent()) {
|
||||||
header('Location: '.$url);
|
header('Location: '.$url);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user