Not found errors raised by id_for use more specific error classes when they exist#583
Conversation
Danger ReportNo issues found. |
dee11c7 to
e613a61
Compare
id_for raises more specific errors when they existe613a61 to
96e3e69
Compare
96e3e69 to
1a8bd62
Compare
dblock
left a comment
There was a problem hiding this comment.
LGTM, thank you! Let's add a section to UPGRADING and bump the version to 3.2.0 since it's not a minor change.
It looks backwards compatible since NotFound errors are also SlackError's? Check?
Sounds good - change pushed.
Yeah - all the specific errors inherit from the base SlackError. Aside from code which is disregarding inheritance (i.e. using |
|
I don't see an UPGRADING change, but otherwise LGTM? |
Apologies! I misread that as just asking for a change to the version string. The new commit adds an entry to UPGRADING |
Problem
Presently the
id_formethod always raises aSlackError. This means that when calling e.g.users_infoone must handle bothUserNotFoundandSlackError-with-a-message-equal-"user_not_found" to actually cover ones bases.Solution
This uses the existing error type deduction mechanism to raise a more specific error when one exists. At the time of writing this will work for all consumers of
id_forPotential issues
The specific errors are subclasses of
SlackError, and therefore will still behave as expected in existingrescues,is_a?calls, etc. Any class equality checks failing to account for inheritance, however, will break.