2.0.0 • Published 9 years ago

json-rpc-error v2.0.0

Weekly downloads
36,482
License
MIT
Repository
github
Last release
9 years ago

JSON RPC 2.0 Error

Error constructors for JSON RPC 2.0 errors as described in the JSON-RPC 2.0 Error Specification

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

@infinitebrahmanuniverse/nolb-json-r@everything-registry/sub-chunk-1985@alayanetwork/web3-provider-engine@deconet/web3-provider-engine@dexon-foundation/eth-json-rpc-infura@dexon-foundation/eth-json-rpc-middleware@dexon-foundation/web3-provider-engine@dexon-foundation/subproviders@bitski/provider-engine@bonsaiswap-lib/lib@bonsaiswapv3/core@bonsaiswapv3/deploy@borealisswap/borealis-swap-lib@callistonetwork/eth-json-rpc-0xinfra@gislik/web3-provider-engineubiq-json-rpc-shokkuwebu-provider-enginesof-json-rpc-infurasof-json-rpc-middlewaresusyweb-provider-enginesquarelink-provider-engine@chakra-swap/core@celo/0x-subproviders@igniswap/igni-swap-lib@afria/afria-libraries@0x-klaytn/subproviders@0x/subproviders@0xproject/subproviders@innoswap/core@eliteswap/v2-core@laodabi/0x-subproviders@juicemx/web3-provider-engine@kodinghandle/bullswap-lib@litedexdev/litedex-core-swap@michael1011/web3-provider-engine@materia-dex/materia-contracts-proxy@olympfin/olymp-swap-lib@xswap/v2-coremikudos-socketio-appmoac-provider-engine@xdcx/subproviderseth-login-controllereth-json-rpc-infura-patchethercore-json-rpc-provider@sudophunk/fulido@ubiqsmart/sparrow-shokku-provider@ubiqsmart/sparrow-ubiq-rpc-provider@vapormask/web3-provider-engine@wanswap/subprovidersmew-coreembark-web3-provider-engine@portis/eth-json-rpc-middleware@portis/web3-provider-engine@platonenterprise/web3-provider-engine@platonnetwork/web3-provider-engine@tsiry/web3-provider-engine@tsunagi/core@thismr/bitmindtest-core@two-point-five/provider-engine@umaprotocol/web3-provider-enginebch-json-rpc-middlewarebitski-providerbitski-truffle-providerptestweb3-provider-enginepweb3-provider-engineirc-json-rpc-infurairc-json-rpc-middlewarejson-rpc-engine-es5json-rpc-server-streamjson-rpc-pocketjson-rpc-client-streamkoa-json-rpc2
2.0.0

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago