Exception: JSONRPC::MethodNotFoundError

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

Overview

JSON-RPC 2.0 Method Not Found Error (-32601)

Raised when the method does not exist / is not available.

Examples:

Create a method not found error

error = JSONRPC::MethodNotFound.new(data: { requested_method: "unknown_method" })

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 = 'The requested RPC method does not exist or is not supported.', data: nil, request_id: nil) ⇒ MethodNotFoundError

Creates a new Method Not Found Error with code -32601

Examples:

Create a method not found error

error = JSONRPC::MethodNotFoundError.new

Create a method not found error with method name

error = JSONRPC::MethodNotFoundError.new(data: { method: "unknown_method" })

Parameters:

  • message (String) (defaults to: 'The requested RPC method does not exist or is not supported.')

    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/method_not_found_error.rb', line 26

def initialize(
  message = 'The requested RPC method does not exist or is not supported.',
  data: nil,
  request_id: nil
)
  super(
    message,
    code: -32_601,
    data:,
    request_id:
  )
end