From dd5fcd61890aaba25a2abf53a40483f1795d830c Mon Sep 17 00:00:00 2001 From: manavo Date: Tue, 2 Dec 2014 11:13:20 +0000 Subject: [PATCH] Better handling of "findOrFail" Eloquent calls, to actually show a useful error message, which is correctly formatted --- app/start/global.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/start/global.php b/app/start/global.php index ed0d4425..f66b89c8 100644 --- a/app/start/global.php +++ b/app/start/global.php @@ -53,6 +53,10 @@ App::error(function(Exception $exception, $code) Log::error($exception); }); +API::error(function (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) { + return Response::make(['error' => $exception->getMessage()], 404); +}); + /* |-------------------------------------------------------------------------- | Maintenance Mode Handler