twingly / twingly-search-api-ruby

:gem: Twingly Blog Search API in Ruby
https://developer.twingly.com/
MIT License
4 stars 0 forks source link

Differentiate between 401 and 402 status codes #80

Closed walro closed 5 years ago

walro commented 5 years ago

Currently we do not differentiate between 401 and 402 errors: https://github.com/twingly/twingly-search-api-ruby/blob/785d8604c2422eee7a1abc26422649fcdc57f861/lib/twingly/search/error.rb#L9-L10

Raising AuthError for 401 class of errors is fine, but for 402 we should probably raise something like LanguageSelectionError, see: https://developer.twingly.com/resources/search/#4xx-client-errors

walro commented 5 years ago

Or possibly PaymentRequiredError as 402 might expand to more things in the future.

jage commented 5 years ago

How about AccessDenied? I.e. we're authorized but don't have access to to this part of the API (language in this case). Or separate to AuthorizationError (lang error) and AuthenticationError (api key error)?

walro commented 5 years ago

Or separate to AuthorizationError (lang error) and AuthenticationError (api key error)?

This sounds good to me

jage commented 5 years ago

Ok, I'm thinking it's easiest if we just remove AuthError when doing this, ie. no deprecation period. I think it's too hard to deprecate it in a reasonable way, i.e. if we'd be able to handle it with the existing error class we wouldn't change it in the first place.