2019-05-20 07:37:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Exceptions;
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
|
|
|
|
|
|
|
class Handler extends ExceptionHandler
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* A list of the exception types that are not reported.
|
|
|
|
*
|
2021-12-02 13:15:53 +01:00
|
|
|
* @var string[]
|
2019-05-20 07:37:41 +02:00
|
|
|
*/
|
|
|
|
protected $dontReport = [
|
|
|
|
//
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A list of the inputs that are never flashed for validation exceptions.
|
|
|
|
*
|
2021-12-02 13:15:53 +01:00
|
|
|
* @var string[]
|
2019-05-20 07:37:41 +02:00
|
|
|
*/
|
|
|
|
protected $dontFlash = [
|
2021-12-02 13:15:53 +01:00
|
|
|
'current_password',
|
2019-05-20 07:37:41 +02:00
|
|
|
'password',
|
|
|
|
'password_confirmation',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
2021-12-02 13:15:53 +01:00
|
|
|
* Register the exception handling callbacks for the application.
|
2019-05-20 07:37:41 +02:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2021-12-02 13:15:53 +01:00
|
|
|
public function register()
|
2019-05-20 07:37:41 +02:00
|
|
|
{
|
2021-12-02 13:15:53 +01:00
|
|
|
$this->renderable(function (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $exception, $request) {
|
2021-09-26 23:49:52 +02:00
|
|
|
return response()->json([
|
|
|
|
'message' => 'not found'], 404);
|
2021-12-02 13:15:53 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$this->renderable(function (InvalidOtpParameterException $exception, $request) {
|
2021-09-17 23:45:08 +02:00
|
|
|
return response()->json([
|
|
|
|
'message' => 'invalid OTP parameters',
|
|
|
|
'reason' => [$exception->getMessage()]
|
|
|
|
], 400);
|
2021-12-02 13:15:53 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$this->renderable(function (InvalidQrCodeException $exception, $request) {
|
2021-09-07 23:01:53 +02:00
|
|
|
return response()->json([
|
|
|
|
'message' => 'not a valid QR code'], 400);
|
2021-12-02 13:15:53 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$this->renderable(function (InvalidSecretException $exception, $request) {
|
2021-09-17 23:45:08 +02:00
|
|
|
return response()->json([
|
|
|
|
'message' => 'not a valid base32 encoded secret'], 400);
|
2021-12-02 13:15:53 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$this->renderable(function (DbEncryptionException $exception, $request) {
|
2021-11-26 11:21:57 +01:00
|
|
|
return response()->json([
|
|
|
|
'message' => $exception->getMessage()], 400);
|
2021-12-02 13:15:53 +01:00
|
|
|
});
|
2019-05-26 16:44:46 +02:00
|
|
|
}
|
2020-11-20 19:06:58 +01:00
|
|
|
}
|