We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fc964f8 commit 78156a0Copy full SHA for 78156a0
app/Exceptions/Handler.php
@@ -3,7 +3,7 @@
3
namespace App\Exceptions;
4
5
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6
-use Throwable;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
7
8
class Handler extends ExceptionHandler
9
{
@@ -34,8 +34,10 @@ class Handler extends ExceptionHandler
34
*/
35
public function register()
36
37
- $this->reportable(function (Throwable $e) {
38
- //
+ $this->renderable(function (NotFoundHttpException $e, $request) {
+ if ($request->wantsJson()) {
39
+ return response()->json(['message' => 'Object not found'], 404);
40
+ }
41
});
42
}
43
0 commit comments