Skip to content

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

@Da9elKH

Description

@Da9elKH

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions