Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-rpc-error

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-rpc-error

JSON RPC 2.0 Errors.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
41K
decreased by-7.49%
Maintainers
1
Weekly downloads
 
Created
Source

JSON RPC 2.0 Error

Error constructors for JSON RPC 2.0 errors as described in the [JSON-RPC 2.0 Error Specification] (http://www.jsonrpc.org/specification#error_object)

codemessagemeaning
-32700Parse errorInvalid JSON was received by the server. An error occurred on the server while parsing the JSON text.
-32600Invalid RequestThe JSON sent is not a valid Request object.
-32601Method not foundThe method does not exist / is not available.
-32602Invalid paramsInvalid method parameter(s).
-32603Internal errorInternal JSON-RPC error.
-32000 to -32099Server errorReserved for implementation-defined server-errors.

Specific errors are instances of the base constructor JsonRpcError, which in turn is an instance of the native JavaScript Error object.

Each error can be constructed with or without the new keyword, for example

var err = new JsonRpcError.ParseError();

is the same as

var err = JsonRpcError.ParseError();

Also see related packages json-rpc-response, json-rpc-request, and json-rpc-notification

Usage

Import the JSON RPC 2.0 error module:

var JsonRpcError = require('json-rpc-error');

JsonRpcError

General base constructor for JSON RPC 2 errors:

new JsonRpcError(message, code[, data]);

Parse error

Invalid JSON was received by the server.

new JsonRpcError.ParseError();

Invalid Request

The JSON sent is not a valid Request object.

new JsonRpcError.InvalidRequest();

Method not found

The method does not exist / is not available.

new JsonRpcError.MethodNotFound();

Invalid params

Invalid method parameter(s).

new JsonRpcError.InvalidParams();

Internal error

Internal JSON-RPC error. The constructor can take an optional error object, in which case the error's message property will be passed on.

new JsonRpcError.InternalError([error]);

Server Error

Reserved for implementation-defined server-errors. Provided error code must be in the range -32000 to -32099.

new JsonRpcError.ServerError(code);

Test

Run unit tests:

$ npm test

Create test coverage report:

$ npm run-script test-cov

License

MIT

Keywords

FAQs

Package last updated on 30 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc