adrema/app/Exceptions/Handler.php

63 lines
1.4 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;
2021-06-21 18:57:38 +02:00
use Zoomyboy\LaravelNami\NamiException;
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.
*
* @param \Throwable $exception
* @return void
*
* @throws \Exception
*/
public function report(Throwable $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @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);
}
}