Exception: ReductoAI::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/reducto_ai/errors.rb

Overview

Base error class for all Reducto API errors.

All API-related exceptions inherit from this class and include HTTP status code and response body for debugging.

Examples:

Handling errors

begin
  client.parse.sync(input: "invalid-url")
rescue ReductoAI::AuthenticationError => e
  puts "Auth failed: #{e.message}"
rescue ReductoAI::ClientError => e
  puts "Client error (#{e.status}): #{e.body}"
rescue ReductoAI::Error => e
  puts "API error: #{e.message}"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status: nil, body: nil) ⇒ Error

Creates a new error instance.

Parameters:

  • message (String, nil) (defaults to: nil)

    Error message

  • status (Integer, nil) (defaults to: nil)

    HTTP status code

  • body (Hash, String, nil) (defaults to: nil)

    Response body



31
32
33
34
35
# File 'lib/reducto_ai/errors.rb', line 31

def initialize(message = nil, status: nil, body: nil)
  super(message)
  @status = status
  @body = body
end

Instance Attribute Details

#bodyHash, ... (readonly)

Returns Response body.

Returns:

  • (Hash, String, nil)

    Response body



24
25
26
# File 'lib/reducto_ai/errors.rb', line 24

def body
  @body
end

#statusInteger? (readonly)

Returns HTTP status code.

Returns:

  • (Integer, nil)

    HTTP status code



21
22
23
# File 'lib/reducto_ai/errors.rb', line 21

def status
  @status
end