stream-ruby icon indicating copy to clipboard operation
stream-ruby copied to clipboard

More specific error classes

Open mostlyobvious opened this issue 5 years ago • 1 comments

I'd be wonderful to be able to dispatch errors by class rather than by checking message they pass.

Currently:

when 401
  raise StreamApiResponseException, error_message(response, 'Bad feed')
when 403
  raise StreamApiResponseException, error_message(response, 'Bad auth/headers')
when 404
  raise StreamApiResponseException, error_message(response, 'url not found')

Having:

UrlNotFound = Class.new(StreamApiResponseException)

when 404
  raise UrlNotFound, error_message(response, 'url not found')

would be backwards compatible and enable responding differently when matching Stream::UrlNotFound === error in application codebase.

mostlyobvious avatar Mar 02 '20 15:03 mostlyobvious

I appreciate this comment, had an issue trying to test for errors and having to guess the underlying implementation when it came to writing a spec @pawelpacana

Josiassejod1 avatar Mar 09 '21 22:03 Josiassejod1

fixed by #142, thanks @groyoh

ferhatelmas avatar Sep 21 '22 15:09 ferhatelmas