-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add watchdog entry if excpetion was thrown #522
Conversation
@@ -527,6 +527,9 @@ 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); | |||
} | |||
|
|||
$severity = $e->getCode() < 500 ? WATCHDOG_NOTICE : WATCHDOG_ERROR; | |||
watchdog('restful', $e->getMessage(), array(), $severity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use watchdog_exception
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know about watchdog_exception
:) I think we should use it only for the below case and when status code >= 500.
@@ -527,6 +527,17 @@ 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we simplify this as:
// 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.
// If the code is 5XX then it is an actual server exception.
$severity = $e->getCode() < 500 ? WATCHDOG_NOTICE : WATCHDOG_ERROR;
watchdog_exception('restful', $e, NULL, array(), $severity);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "problem" with watchdog_exception() is that it adds the line number where exception was thrown. However for exceptions < 500, we don't really need that info, since it's not really a server error, but just the way RESTful is taking advantage of exceptions to short circuit the flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me.
Add watchdog entry if excpetion was thrown
This was ported to 7.x-2.x in #726. |
#521