Skip to content

Not found errors raised by id_for use more specific error classes when they exist#583

Merged
dblock merged 3 commits intoslack-ruby:masterfrom
eizengan:eizengan/id_for_error_classes
Feb 23, 2026
Merged

Not found errors raised by id_for use more specific error classes when they exist#583
dblock merged 3 commits intoslack-ruby:masterfrom
eizengan:eizengan/id_for_error_classes

Conversation

@eizengan
Copy link
Contributor

Problem

Presently the id_for method always raises a SlackError. This means that when calling e.g. users_info one must handle both UserNotFound and SlackError-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_for

Potential issues

The specific errors are subclasses of SlackError, and therefore will still behave as expected in existing rescues, is_a? calls, etc. Any class equality checks failing to account for inheritance, however, will break.

@github-actions
Copy link

github-actions bot commented Feb 19, 2026

Danger Report

No issues found.

View run

@eizengan eizengan force-pushed the eizengan/id_for_error_classes branch from dee11c7 to e613a61 Compare February 19, 2026 15:23
@eizengan eizengan changed the title id_for raises more specific errors when they exist Not found errors raised by id_for use more specific error classes when they exist Feb 19, 2026
@eizengan eizengan force-pushed the eizengan/id_for_error_classes branch from e613a61 to 96e3e69 Compare February 19, 2026 15:25
@eizengan eizengan force-pushed the eizengan/id_for_error_classes branch from 96e3e69 to 1a8bd62 Compare February 19, 2026 15:28
@eizengan eizengan marked this pull request as ready for review February 19, 2026 15:31
Copy link
Collaborator

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@eizengan
Copy link
Contributor Author

eizengan commented Feb 22, 2026

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.

Sounds good - change pushed.

It looks backwards compatible since NotFound errors are also SlackError's? Check?

Yeah - all the specific errors inherit from the base SlackError. Aside from code which is disregarding inheritance (i.e. using error.class == SlackError instead of error.is_a? SlackError) this should be backwards compatible. Notably, rescue SlackError respects inheritance in this manner.

dblock
dblock previously approved these changes Feb 23, 2026
@dblock
Copy link
Collaborator

dblock commented Feb 23, 2026

I don't see an UPGRADING change, but otherwise LGTM?

@eizengan
Copy link
Contributor Author

eizengan commented Feb 23, 2026

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

@dblock dblock merged commit b312307 into slack-ruby:master Feb 23, 2026
11 checks passed
@eizengan eizengan deleted the eizengan/id_for_error_classes branch February 23, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants