self.for

in lib/anthropic/errors.rb [102:133]


      def self.for(url:, status:, body:, request:, response:, message: nil)
        kwargs = {
          url: url,
          status: status,
          body: body,
          request: request,
          response: response,
          message: message
        }

        case status
        in 400
          Anthropic::Errors::BadRequestError.new(**kwargs)
        in 401
          Anthropic::Errors::AuthenticationError.new(**kwargs)
        in 403
          Anthropic::Errors::PermissionDeniedError.new(**kwargs)
        in 404
          Anthropic::Errors::NotFoundError.new(**kwargs)
        in 409
          Anthropic::Errors::ConflictError.new(**kwargs)
        in 422
          Anthropic::Errors::UnprocessableEntityError.new(**kwargs)
        in 429
          Anthropic::Errors::RateLimitError.new(**kwargs)
        in (500..)
          Anthropic::Errors::InternalServerError.new(**kwargs)
        else
          Anthropic::Errors::APIStatusError.new(**kwargs)
        end
      end