Improving error reporting API

This commit is contained in:
David Bomba 2016-02-17 09:12:34 +11:00
parent 746b6ef362
commit 31720b59fd

View File

@ -290,9 +290,15 @@ class InvoiceApiController extends BaseAPIController
if(!$invoice) if(!$invoice)
return $this->errorResponse(['message'=>'Invoice does not exist.'], 400); return $this->errorResponse(['message'=>'Invoice does not exist.'], 400);
$emailAction = $this->mailer->sendInvoice($invoice); try {
$this->mailer->sendInvoice($invoice);
}
catch(\Exception $e)
{
$this->errorResponse(['message'=>'There was an error sending the invoice'], 400);
}
if(($error) || ($emailAction === FALSE)) { if($error) {
return $this->errorResponse(['message'=>'There was an error sending the invoice'], 400); return $this->errorResponse(['message'=>'There was an error sending the invoice'], 400);
} }
else { else {