mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-20 16:31:33 +02:00
Improving error reporting API
This commit is contained in:
parent
31720b59fd
commit
170ee5a40b
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user