Exception: JSONRPC::InternalError

Inherits:
Error
  • Object
show all
Defined in:
lib/jsonrpc/errors/internal_error.rb

Overview

JSON-RPC 2.0 Internal Error (-32603)

Raised when there was an internal JSON-RPC error.

Examples:

Create an internal error

error = JSONRPC::Errors::InternalError.new(data: { details: 'Unexpected server error' })

Instance Attribute Summary

Attributes inherited from Error

#code, #data, #message, #request_id

Instance Method Summary collapse

Methods inherited from Error

#to_h, #to_json, #to_response

Constructor Details

#initialize(message = 'Internal JSON-RPC error.', data: nil, request_id: nil) ⇒ InternalError

Creates a new Internal Error with code -32603

Examples:

Create an internal error

error = JSONRPC::InternalError.new

Create an internal error with exception details

error = JSONRPC::InternalError.new(data: { exception: "NoMethodError" }, request_id: 1)

Parameters:

  • message (String) (defaults to: 'Internal JSON-RPC error.')

    short description of the error

  • data (Hash, Array, String, Number, Boolean, nil) (defaults to: nil)

    additional error information

  • request_id (String, Integer, nil) (defaults to: nil)

    the request identifier



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jsonrpc/errors/internal_error.rb', line 26

def initialize(
  message = 'Internal JSON-RPC error.',
  data: nil,
  request_id: nil
)
  super(
    message,
    code: -32_603,
    data:,
    request_id:
  )
end