GetStream / stream-ruby

Ruby Client - Build Activity Feeds & Streams with GetStream.io
https://getstream.io
BSD 3-Clause "New" or "Revised" License
85 stars 32 forks source link

More specific error classes #121

Closed mostlyobvious closed 2 years ago

mostlyobvious commented 4 years ago

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.

Josiassejod1 commented 3 years ago

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

ferhatelmas commented 2 years ago

fixed by #142, thanks @groyoh