provide better message when texture is missing
This commit is contained in:
parent
fe1a03fd8f
commit
d10bcae197
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
@ -16,12 +17,24 @@ class Handler extends ExceptionHandler
|
||||||
\Illuminate\Auth\AuthenticationException::class,
|
\Illuminate\Auth\AuthenticationException::class,
|
||||||
\Illuminate\Auth\Access\AuthorizationException::class,
|
\Illuminate\Auth\Access\AuthorizationException::class,
|
||||||
\Symfony\Component\HttpKernel\Exception\HttpException::class,
|
\Symfony\Component\HttpKernel\Exception\HttpException::class,
|
||||||
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
|
|
||||||
\Illuminate\Validation\ValidationException::class,
|
\Illuminate\Validation\ValidationException::class,
|
||||||
\Illuminate\Session\TokenMismatchException::class,
|
\Illuminate\Session\TokenMismatchException::class,
|
||||||
|
ModelNotFoundException::class,
|
||||||
PrettyPageException::class,
|
PrettyPageException::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function render($request, Throwable $exception)
|
||||||
|
{
|
||||||
|
if ($exception instanceof ModelNotFoundException) {
|
||||||
|
$model = $exception->getModel();
|
||||||
|
if (Str::endsWith($model, 'Texture')) {
|
||||||
|
$exception = new ModelNotFoundException(trans('skinlib.non-existent'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::render($request, $exception);
|
||||||
|
}
|
||||||
|
|
||||||
protected function convertExceptionToArray(Throwable $e)
|
protected function convertExceptionToArray(Throwable $e)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,10 @@ class SkinlibControllerTest extends TestCase
|
||||||
|
|
||||||
public function testInfo()
|
public function testInfo()
|
||||||
{
|
{
|
||||||
|
$this->get(route('texture.info', ['texture' => 0]))
|
||||||
|
->assertNotFound()
|
||||||
|
->assertSee(trans('skinlib.non-existent'));
|
||||||
|
|
||||||
$texture = factory(Texture::class)->create();
|
$texture = factory(Texture::class)->create();
|
||||||
$this->get(route('texture.info', ['texture' => $texture]))
|
$this->get(route('texture.info', ['texture' => $texture]))
|
||||||
->assertJson($texture->toArray());
|
->assertJson($texture->toArray());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user