Skip to content

Commit

Permalink
Merge pull request #522 from RESTful-Drupal/521
Browse files Browse the repository at this point in the history
Add watchdog entry if excpetion was thrown
  • Loading branch information
e0ipso committed Jun 1, 2015
2 parents 2fa6dbc + c1cc444 commit e75c2e3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions restful.module
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,26 @@ function restful_menu_process_callback($resource_name, $version = NULL) {
foreach ($e->getHeaders() as $header_name => $header_value) {
drupal_add_http_header($header_name, $header_value);
}

if ($e->getCode() < 500) {
// Even though it's an exception, it's in fact not a server error - it
// might be just access denied, or a bad request, so we just want to log
// it, but without marking it as an actual exception.
watchdog('restful', $e->getMessage());
}
else {
// This one should really be considered as an error.
watchdog_exception('restful', $e);
}
}
catch (Exception $e) {
$result = array(
'type' => 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1',
'title' => $e->getMessage(),
'status' => 500,
);

watchdog_exception('restful', $e);
}

// Adhere to the API Problem draft proposal.
Expand Down

0 comments on commit e75c2e3

Please sign in to comment.