mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improving error reporting API
This commit is contained in:
parent
746b6ef362
commit
31720b59fd
@ -284,15 +284,21 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
$error = null;
|
$error = null;
|
||||||
|
|
||||||
Log::info($data);
|
Log::info($data);
|
||||||
|
|
||||||
$invoice = Invoice::scope($data['id'])->withTrashed()->first();
|
$invoice = Invoice::scope($data['id'])->withTrashed()->first();
|
||||||
|
|
||||||
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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user