Skip to content

Commit

Permalink
use yarn; docstring fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks committed Jan 31, 2020
1 parent 53d76f6 commit 5452001
Show file tree
Hide file tree
Showing 8 changed files with 1,747 additions and 2,132 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## 2.0.0 (Current)

- **Exports**
- `errors` renamed `ethErrors`
- `JsonRpcError` renamed `EthereumRpcError`
Expand Down Expand Up @@ -30,6 +31,7 @@
- Updated affected interfaces

## 1.1.0

- `serializeError`
- If the object passed to the function has a `.message` property,
it will preferred over the `.message` property of the fallback error when
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# eth-json-rpc-errors

Errors for the
[Ethereum JSON RPC](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md)
[Ethereum JSON RPC](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md)
and
[Ethereum Provider](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md),
and [making unknown errors compliant with either spec](#parsing-unknown-errors).

## Basic Usage

```js
import { ethErrors } from 'eth-json-rpc-errors'

Expand All @@ -27,7 +28,7 @@ throw ethErrors.provider.unauthorized('my custom message')

## Usage

Installation: `npm install eth-json-rpc-errors`
Installation: `npm install eth-json-rpc-errors` or `yarn add eth-json-rpc-errors`

Import using ES6 syntax (no default export) or Node `require`.

Expand Down Expand Up @@ -74,6 +75,7 @@ response.error = ethErrors.provider.custom({
```

### Parsing Unknown Errors

```js
// this is useful for ensuring your errors are standardized
import { serializeError } from 'eth-json-rpc-errors'
Expand All @@ -82,7 +84,7 @@ import { serializeError } from 'eth-json-rpc-errors'
// it will be added as error.data.originalError
response.error = serializeError(maybeAnError)

// you can add a custom fallback error code and message if desired
// you can add a custom fallback error code and message if desired
const fallbackError = { code: 4999, message: 'My custom error.' }
response.error = serializeError(maybeAnError, fallbackError)

Expand All @@ -97,14 +99,15 @@ response.error = serializeError(maybeAnError, fallbackError)
```

### Other Exports

```js
/**
* TypeScript interfaces
*/
import {
// these describe to the corresponding exports from index.js
IEthErrors, IEthereumRpcError, IEthereumProviderError, ISerializeError,
// these describe the options argument to error getters in ethErrors
// these describe the options argument to error getters in ethErrors
IErrorOptions, IRpcServerErrorOptions, IProviderCustomErrorOptions
} from 'eth-json-rpc-errors/@types'

Expand Down
Loading

0 comments on commit 5452001

Please sign in to comment.