Exception: JSONRPC::InvalidParamsError

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

Overview

JSON-RPC 2.0 Invalid Params Error (-32602)

Raised when invalid method parameter(s) were provided.

Examples:

Create an invalid params error

error = JSONRPC::InvalidParamsError.new(data: { details: "Expected array of integers" })

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 = 'Invalid method parameter(s).', data: nil, request_id: nil) ⇒ InvalidParamsError

Creates a new Invalid Params Error with code -32602

Examples:

Create an invalid params error

error = JSONRPC::InvalidParamsError.new

Create an invalid params error with validation details

error = JSONRPC::InvalidParamsError.new(data: { errors: ["param a is required"] })

Parameters:

  • message (String) (defaults to: 'Invalid method parameter(s).')

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

def initialize(
  message = 'Invalid method parameter(s).',
  data: nil,
  request_id: nil
)
  super(
    message,
    code: -32_602,
    data:,
    request_id:
  )
end