Anyone know what is the best way to handle errors in Laravel, there is any rules or something to follow ?
Currently i\'m doing this :
public function st
In your handler.php This should work for handling 404 Exception.
public function render($request, Throwable $exception ){ if ($exception instanceof ModelNotFoundException) { return response()->json([ 'error' => 'Data not found' ], 404); } return parent::render($request, $exception); }