I just spent a few hours debugging a 500 response code from the services module. It was very frustrating, as we were getting a 500 error, which indicates a server error:
The server encountered an unexpected condition which prevented it from fulfilling the request.
The Services module is pushing this error here (RESTServer.inc):
$error_header_status_message = $this->formatHttpHeaderStatusMessage('500 Internal Server Error', "An error occurred ({$error_code}): {$error_message}");
The big issue here was that there was no data in the logs whatsoever to indicate what the problem was. Nothing in our apache error log, nothing in the Drupal watchdog. This left us scratching our heads, as our client was not showing us the error, only the error code.
When this error occurs, the error should be written to the watchdog for debugging purposes. I'm attaching a patch that will do this.
Comment | File | Size | Author |
---|---|---|---|
#3 | services-write_500_error_to_watchdog-2521436-3.patch | 654 bytes | marcingy |
Comments
Comment #1
Jaypan CreditAttribution: Jaypan at Jaypan commentedAttaching patch
Comment #2
marcingy CreditAttribution: marcingy commentedComment #3
marcingy CreditAttribution: marcingy as a volunteer commentedActually why not use watchdog_exception().
Comment #4
Jaypan CreditAttribution: Jaypan at Jaypan commentedInteresting, that's a new function for me. That looks to be a better option.
Comment #5
kylebrowning CreditAttribution: kylebrowning commented