Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teamtailor::Error.from_response doesn't handle all response code cases #7

Open
Da9elKH opened this issue Aug 27, 2021 · 0 comments
Open

Comments

@Da9elKH
Copy link
Contributor

Da9elKH commented Aug 27, 2021

In production we sometimes get TypeError "exception object expected", from the call method in client.rb originating from the following lines:

raise Teamtailor::Error.from_response(
body: response.body,
status: response.code
)

I think it's because the Teamtailor::Error.from_response method doesn't have an "else"-statement:

def self.from_response(body:, status:)
case status
when 401
Teamtailor::UnauthorizedRequestError.new
when 406
json_response = JSON.parse(body)
Teamtailor::InvalidApiVersionError.new(
json_response.dig("errors", "detail")
)
when 422
json_response = JSON.parse(body)
Teamtailor::UnprocessableEntityError.new(
json_response.dig("errors", 0, "detail")
)
end
end

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

No branches or pull requests

1 participant