Reputation: 131
In order for Google Cloud Tasks to automatically be re-queued I need my Laravel 7 app to return a 500 error, but everything short of a call to abort() seems to want to return a 200. I know that this ought to work:
return response('No dice son, you gotta work-a late.', 500);
...but no, the task still receives 200 and thus it's deleted from the queue as though it had succeeded.
The reason I'd prefer to avoid abort('Fall down go boom')
is that it also raises an exception in Stackdriver, and that's unnecessary since I'm returning this particular error when a third party's API fails to provide data. In the event of errors on my side I'm killing the job outright.
The flow of my code is that I raise a custom exception when the third-party API returns null, then catch that exception and in the handler I call another method that does the work of cleaning up the job, which is when I intended to return 500... though right now I'm calling abort('No worky')
.
Is there some minutia in the docs that I managed to overlook?
Upvotes: 0
Views: 178
Reputation: 76759
In order to send HTTP 500, this usually would be:
return abort(500, 'Internal Server Error');
And the method usally doesn't matter, as it is just a helper, which returns Response
.
Changing the error message does not chenge the fact that it's an intenral server error - and when returning 500, it is probably normal to have it logged as an error.
Upvotes: 2