12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Exceptions;
- use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
- use Illuminate\Support\Arr;
- use Illuminate\Validation\ValidationException;
- class Handler extends ExceptionHandler
- {
-
- protected $levels = [
- ];
-
- protected $dontReport = [
- ];
-
- protected $dontFlash = [
- 'current_password',
- 'password',
- 'password_confirmation',
- ];
-
- public function register()
- {
- $this->reportable(function (ClientException $e) {
- logger()->warning($e->getMessage(), array_merge(request()->all(), request()->headers->all()));
- return false;
- });
- $this->renderable(function (ClientException $e) {
- return response()->json([
- 'code' => 400,
- "error" => $e->getMessage(),
- ], 200);
- });
- $this->renderable(function (ValidationException $e) {
- $msg = Arr::first($e->errors());
- return response()->json([
- "error" => $msg[0],
- "code" => 400,
- ]);
- });
- }
- }
|