-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
RFC: Web API error response_metadata is buried #310
Comments
I think metadata is designed to add additional detail and not be source of error. Would logging the error with complete metadata be more appropriate than throwing it into the error message? |
I am fine with your approach btw, but I don’t think this should be optional. I don’t see why it wouldn’t become the new default. Nobody is relying or should be relying on text for conditional workflow and we can document this in upgrading just in case. |
Regarding your first suggestion:
I agree — you might be right here, I just don't know the best way to log the complete metadata other than throwing it into the error message 😊. Whether it would be with a change in this library, or simply a configuration in my app. Do you have any suggestions for how to do that? Regarding your second comment, making it the new default actually would break code in our app where we look at the error's rescue Slack::Web::Api::Error => e
raise e unless e.message == 'not_in_channel'
end My proposed change would change the value of |
Here's a related idea: I wonder if it would make more sense for each of Slack's error codes to have its own error class. For instance All of them would be subclasses of That would simplify code like this: rescue Slack::Web::Api::Errors::SlackError => e
raise e unless e.error == 'not_in_channel'
# do something
end to this: rescue Slack::Web::Api::Errors::NotInChannel
# do something
end If we like this idea, then it should be easy enough to pull all the types from the official API spec. Here's one thing that gives me pause: I tried pulling the list of errors from the spec to see how many there are, and the number is 171, which seems like potentially too many error subclasses. Thoughts? |
I think it's a great idea @jmanian and I wouldn't worry about the number of classes. It's a definite improvement for the developer as we constantly compare |
Should we close this @jmanian ? |
In some of the more recent Web API methods the most relevant error information is given in the
response_metadata
. For instance here's an example of Slack's response body for a bad call toviews.open
:The
error
value ofinvalid_arguments
is basically useless on its own — it's necessary to look at theresponse_metadata
to understand the problem with the request.Currently this library pulls out the
error
value and uses this for themessage
onSlackError
(here). It's possible to access thereseponse_metadata
withslack_error.response.body.response_metadata
. However my problem is that when an error is raised my logs only show theerror
, because that is themessage
(and as far as I can tell,raise
printsClass: message
).My goal is to get the
response_metadata
into my logs. Here's one idea that I have for a feature in this library that would achieve that:verbose_web_api_errors
?).message
onSlackError
will be the entire body as JSON, rather than just theerror
.SlackError
would also gain a new attribute, perhapserror
, which would be the value oferror
from Slack's response, so that this is easily accessed even when the verbose option is being used.SlackError
would also gain a new attributeresponse_metadata
containing just theresponse_metadata
(as a hash-like object).What do you think of this approach? I don't know much about logging, so maybe there's a better approach to this, either within this library or simply in my own app.
The text was updated successfully, but these errors were encountered: