Class: GeminiCraft::ResponseHandler
- Inherits:
-
Object
- Object
- GeminiCraft::ResponseHandler
- Defined in:
- lib/gemini_craft/client.rb
Instance Method Summary collapse
- #handle_response(response) ⇒ Object
-
#initialize(client) ⇒ ResponseHandler
constructor
A new instance of ResponseHandler.
Constructor Details
#initialize(client) ⇒ ResponseHandler
Returns a new instance of ResponseHandler.
272 273 274 |
# File 'lib/gemini_craft/client.rb', line 272 def initialize(client) @client = client end |
Instance Method Details
#handle_response(response) ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/gemini_craft/client.rb', line 276 def handle_response(response) case response.status when 200 JSON.parse(response.body) when 400 handle_client_error(response, "Bad Request") when 401 raise AuthenticationError, "Invalid API key or authentication failed" when 403 raise AuthorizationError, "Access forbidden - check your API permissions" when 404 raise NotFoundError, "Model or endpoint not found" when 429 raise RateLimitError, "Rate limit exceeded - please slow down your requests" when 500..599 raise ServerError, "API server error (#{response.status}): The server encountered an error" else raise APIError, "Unknown API error (#{response.status})" end end |