stream-ruby
stream-ruby copied to clipboard
More specific error classes
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.
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
fixed by #142, thanks @groyoh