Skip to content

Commit

Permalink
404 error page
Browse files Browse the repository at this point in the history
  • Loading branch information
veneliniliev committed Apr 6, 2017
1 parent 810df62 commit ce09bfc
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
27 changes: 27 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace ProVision\Administration\Exceptions;

use Exception;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class Handler extends \App\Exceptions\Handler
{

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
if ($exception instanceof NotFoundHttpException) {
return response()->view('administration::errors.404', compact('exception'), 404);
}

return parent::render($request, $exception);
}

}
7 changes: 6 additions & 1 deletion app/Providers/AdministrationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use ProVision\Administration\Administration;
use ProVision\Administration\Exceptions\Handler;
use ProVision\Administration\Http\Middleware\HttpsProtocol;
use ProVision\Administration\Http\Middleware\NonWww;

Expand Down Expand Up @@ -311,6 +312,11 @@ public function register()
__DIR__ . '/../../config/laravel-form-builder.php', 'laravel-form-builder'
);

/**
* Exception handler
*/
$this->app->singleton(\Illuminate\Contracts\Debug\ExceptionHandler::class, Handler::class);

/*
* Register the service provider for the dependency.
*/
Expand Down Expand Up @@ -391,7 +397,6 @@ public function register()
//non-WWW redirect
$this->app['router']->pushMiddlewareToGroup('web', NonWww::class);


/*
* Commands
*/
Expand Down
2 changes: 2 additions & 0 deletions resources/views/errors/404.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
</p>
@endif

<a href="{{url('/')}}"> << Go back</a>

</div>
</div>
</section>
Expand Down
21 changes: 21 additions & 0 deletions resources/views/errors/500.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@extends('administration::layouts.error')

@section('content')
<section class="content">
<div class="error-page">
<h2 class="headline text-red"> 500</h2>

<div class="error-content">
<br/>
<h3><i class="fa fa-warning text-red"></i> Internal Server Error.</h3>

@if(!empty($exception->getMessage()))
<p>
{{$exception->getMessage()}}
</p>
@endif

</div>
</div>
</section>
@stop

0 comments on commit ce09bfc

Please sign in to comment.