Exception: JSONRPC::InvalidRequestError

Inherits:
Error
  • Object
show all
Defined in:
lib/jsonrpc/errors/invalid_request_error.rb,
sig/jsonrpc/errors/invalid_request_error.rbs

Overview

JSON-RPC 2.0 Invalid Request Error (-32600)

Raised when the JSON sent is not a valid Request object.

Examples:

Create an invalid request error

error = JSONRPC::InvalidRequestError.new(data: { details: "Method must be a string" })

API:

  • public

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, #validate_code, #validate_message

Constructor Details

#initialize(message = 'The JSON payload was valid JSON, but not a valid JSON-RPC Request object.', data: nil, request_id: nil) ⇒ InvalidRequestError

Creates a new Invalid Request Error with code -32600

Examples:

Create an invalid request error

error = JSONRPC::InvalidRequestError.new

Create an invalid request error with custom data

error = JSONRPC::InvalidRequestError.new(data: { field: "missing jsonrpc" })

Parameters:

  • (defaults to: 'The JSON payload was valid JSON, but not a valid JSON-RPC Request object.')

    short description of the error

  • (defaults to: nil)

    additional error information

  • (defaults to: nil)

    the request identifier

  • (defaults to: nil)
  • (defaults to: nil)

API:

  • public



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jsonrpc/errors/invalid_request_error.rb', line 28

def initialize(
  message = 'The JSON payload was valid JSON, but not a valid JSON-RPC Request object.',
  data: nil,
  request_id: nil
)
  super(
    message,
    code: -32_600,
    data:,
    request_id:
  )
end