Exception: A2A::Error

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

Overview

Base error class for A2A protocol errors.

Each subclass carries its own JSON-RPC error code, HTTP status, and structured error data. The handler layer rescues these and calls #to_h to populate env for the binding layer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, code:, http_status: 400) ⇒ Error

Returns a new instance of Error.



40
41
42
43
44
# File 'lib/a2a/errors.rb', line 40

def initialize(message, code:, http_status: 400)
  @code        = code
  @http_status = http_status
  super(message)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



38
39
40
# File 'lib/a2a/errors.rb', line 38

def code
  @code
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



38
39
40
# File 'lib/a2a/errors.rb', line 38

def http_status
  @http_status
end

Instance Method Details

#error_dataObject



46
# File 'lib/a2a/errors.rb', line 46

def error_data = nil

#to_hObject



48
49
50
51
52
# File 'lib/a2a/errors.rb', line 48

def to_h
  h = { code: code, http_status: http_status, message: message }
  h[:data] = error_data if error_data
  h
end