Class: GroqRuby::ErrorMapper
- Inherits:
-
Object
- Object
- GroqRuby::ErrorMapper
- Defined in:
- lib/groq_ruby/error_mapper.rb
Overview
Maps an HTTP status code + parsed body to the matching APIStatusError subclass. Single-purpose: status in, exception instance out.
Constant Summary collapse
- STATUS_CLASSES =
{ 400 => BadRequestError, 401 => AuthenticationError, 403 => PermissionDeniedError, 404 => NotFoundError, 409 => ConflictError, 422 => UnprocessableEntityError, 429 => RateLimitError }.freeze
Class Method Summary collapse
Class Method Details
.call(status:, headers:, body:) ⇒ APIStatusError
19 20 21 22 23 |
# File 'lib/groq_ruby/error_mapper.rb', line 19 def self.call(status:, headers:, body:) klass = resolve_class(status) = (body) || "Groq API returned status #{status}" klass.new(, status: status, headers: headers, body: body) end |