Skip to content

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

Open
eizengan wants to merge 1 commit intoslack-ruby:masterfrom
eizengan:eizengan/id_for_error_classes
Open

Not found errors raised by id_for use more specific error classes when they exist#583
eizengan wants to merge 1 commit 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?

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

Comments