Exception: JSONRPC::InvalidRequestError

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

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" })

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 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:

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

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

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