Exception: JSONRPC::ParseError

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

Overview

JSON-RPC 2.0 Parse Error (-32700)

Raised when invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.

Examples:

Create a parse error

error = JSONRPC::ParseError.new(data: { details: "Unexpected end of input" })

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 JSON was received by the server. An error occurred on the server while parsing the JSON text.', data: nil) ⇒ ParseError

Creates a new Parse Error with code -32700

Examples:

Create a parse error with default message

error = JSONRPC::ParseError.new

Create a parse error with custom data

error = JSONRPC::ParseError.new(data: { detail: "Unexpected end of input" })

Parameters:

  • message (String) (defaults to: 'Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.')

    short description of the error

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

    additional error information



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

def initialize(
  message = 'Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.',
  data: nil
)
  super(
    message,
    code: -32_700,
    data: data
  )
end