|
@@ -3,6 +3,7 @@
|
|
|
namespace App\Exceptions;
|
|
|
|
|
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
|
|
+use Illuminate\Validation\ValidationException;
|
|
|
use Throwable;
|
|
|
|
|
|
class Handler extends ExceptionHandler
|
|
@@ -22,7 +23,6 @@ class Handler extends ExceptionHandler
|
|
|
* @var array<int, class-string<\Throwable>>
|
|
|
*/
|
|
|
protected $dontReport = [
|
|
|
- //
|
|
|
];
|
|
|
|
|
|
/**
|
|
@@ -44,7 +44,15 @@ class Handler extends ExceptionHandler
|
|
|
public function register()
|
|
|
{
|
|
|
$this->reportable(function (Throwable $e) {
|
|
|
- //
|
|
|
+ return response()->json([
|
|
|
+ "error" => $e->getMessage(),
|
|
|
+ ], 400);
|
|
|
+ });
|
|
|
+ $this->renderable(function (ValidationException $e) {
|
|
|
+
|
|
|
+ return response()->json([
|
|
|
+ "error" =>json_encode($e->errors())
|
|
|
+ ], 400);
|
|
|
});
|
|
|
}
|
|
|
}
|