adrema/app/Exceptions/Handler.php

60 lines
1.3 KiB
PHP
Raw Normal View History

2020-04-10 20:32:12 +02:00
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
2022-02-19 15:18:24 +01:00
use Illuminate\Validation\ValidationException;
2020-04-10 20:32:12 +02:00
use Throwable;
2022-02-19 15:18:24 +01:00
use Zoomyboy\LaravelNami\LoginException;
2020-04-10 20:32:12 +02:00
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
2022-01-02 12:32:57 +01:00
* @var string[]
2020-04-10 20:32:12 +02:00
*/
protected $dontReport = [
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
2022-01-02 12:32:57 +01:00
* @var string[]
2020-04-10 20:32:12 +02:00
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Report or log an exception.
*
* @return void
*
* @throws \Exception
*/
public function report(Throwable $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
2022-03-11 20:19:17 +01:00
* @param \Illuminate\Http\Request $request
*
2020-04-10 20:32:12 +02:00
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
2022-02-19 15:18:24 +01:00
if ($exception instanceof LoginException) {
throw ValidationException::withMessages(['nami' => 'NaMi Login fehlgeschlagen.']);
}
2020-04-10 20:32:12 +02:00
return parent::render($request, $exception);
}
}