From 170ee5a40b789d603eab5790047df4cab4f77710 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 17 Feb 2016 09:28:00 +1100 Subject: [PATCH] Improving error reporting API --- app/Http/Controllers/InvoiceApiController.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index 17259da12a..350869fec8 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -283,22 +283,16 @@ class InvoiceApiController extends BaseAPIController $data = Input::all(); $error = null; - Log::info($data); - $invoice = Invoice::scope($data['id'])->withTrashed()->first(); if(!$invoice) return $this->errorResponse(['message'=>'Invoice does not exist.'], 400); - try { - $this->mailer->sendInvoice($invoice); - } - catch(\Exception $e) - { - $this->errorResponse(['message'=>'There was an error sending the invoice'], 400); - } - if($error) { + $emailResponse = $this->mailer->sendInvoice($invoice, false, false); + + + if($emailResponse === FALSE) { return $this->errorResponse(['message'=>'There was an error sending the invoice'], 400); } else {