eth-rpc-errors
Advanced tools
Comparing version 2.1.1 to 3.0.0
@@ -8,2 +8,9 @@ # Changelog | ||
## [3.0.0] | ||
### Changed | ||
- Second argument of `serializeError` is now an options object ([#22](https://github.com/MetaMask/eth-rpc-errors/pull/22)) | ||
- Error stacks are no longer serialized by default by `serializeError` ([#22](https://github.com/MetaMask/eth-rpc-errors/pull/22)) | ||
## [2.1.0] - 2020-05-11 | ||
@@ -14,6 +21,6 @@ | ||
- New/missing errors: | ||
- `ethErrors.provider` ([EIP 1193](https://eips.ethereum.org/EIPS/eip-1474#provider-errors)) | ||
- `ethErrors.provider` ([EIP-1193](https://eips.ethereum.org/EIPS/eip-1474#provider-errors)) | ||
- `.disconnected`, `4900` | ||
- `.chainDisconnected`, `4901` | ||
- `ethErrors.rpc` ([EIP 1474](https://eips.ethereum.org/EIPS/eip-1474#error-codes)) | ||
- `ethErrors.rpc` ([EIP-1474](https://eips.ethereum.org/EIPS/eip-1474#error-codes)) | ||
- `.limitExceeded`, `-32005` | ||
@@ -36,8 +43,8 @@ | ||
- Added missing | ||
[EIP 1474 errors](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md) | ||
[EIP-1474 errors](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md) | ||
- Added corresponding codes and messages | ||
- **Namespacing** | ||
- EIP 1474 (which includes JSON RPC 2.0) errors now namespaced under `ethErrors.rpc` | ||
- EIP-1474 (which includes JSON RPC 2.0) errors now namespaced under `ethErrors.rpc` | ||
- JSON RPC 2.0 errors were formerly under `errors.jsonRpc` | ||
- EIP 1193 errors now namespaced under `ethErrors.provider` | ||
- EIP-1193 errors now namespaced under `ethErrors.provider` | ||
- Formerly under `errors.eth` | ||
@@ -44,0 +51,0 @@ - Most error getters now take a single, *optional* `opts` argument, which |
{ | ||
"name": "eth-rpc-errors", | ||
"version": "2.1.1", | ||
"version": "3.0.0", | ||
"description": "Ethereum RPC and Provider errors.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -73,10 +73,15 @@ | ||
* returned object's data.originalError property. | ||
* Adds a 'stack' property if it exists on the given error. | ||
* | ||
* @param {any} error - The error to serialize. | ||
* @param {object} fallbackError - The custom fallback error values if the | ||
* given error is invalid. | ||
* @return {object} A standardized error object. | ||
* @param {Object} [options] - An options object. | ||
* @param {Object} [options.fallbackError] - The custom fallback error values if | ||
* the given error is invalid. | ||
* @param {boolean} [options.shouldIncludeStack] - Whether the 'stack' property | ||
* of the given error should be included on the serialized error, if present. | ||
* @return {Object} A standardized, plain error object. | ||
*/ | ||
function serializeError (error, fallbackError = FALLBACK_ERROR) { | ||
function serializeError ( | ||
error, | ||
{ fallbackError = FALLBACK_ERROR, shouldIncludeStack = false } = {}, | ||
) { | ||
@@ -89,3 +94,3 @@ if ( | ||
throw new Error( | ||
'fallbackError must contain integer number code and string message.', | ||
'Must provide fallback error with integer number code and string message.', | ||
) | ||
@@ -124,3 +129,3 @@ } | ||
if (error && error.stack) { | ||
if (shouldIncludeStack && error && typeof error.stack === 'string') { | ||
serialized.stack = error.stack | ||
@@ -127,0 +132,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30445
678