From a29512001525102cbbb7fea223d4c3a94c053fc1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 15 Feb 2016 21:57:58 +1100 Subject: [PATCH] Client API Error handling --- app/Http/Controllers/ClientApiController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ClientApiController.php b/app/Http/Controllers/ClientApiController.php index 6cd91d1d09f1..fa4c9df266d5 100644 --- a/app/Http/Controllers/ClientApiController.php +++ b/app/Http/Controllers/ClientApiController.php @@ -1,5 +1,6 @@ action == ACTION_ARCHIVE) { - $client = Client::scope($publicId)->firstOrFail(); + + try { + $client = Client::scope($publicId)->firstOrFail(); + } catch (ModelNotFoundException $e) { + return $this->errorResponse(['message'=>'Record not found'], 400); + } + $this->clientRepo->archive($client); $transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));