Skip to content

Commit b167c1e

Browse files
committed
Update README
1 parent 4d08522 commit b167c1e

File tree

1 file changed

+19
-50
lines changed

1 file changed

+19
-50
lines changed

README.md

Lines changed: 19 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,22 @@ import modernErrorsProcess from 'modern-errors-process'
4343
export const AnyError = modernErrors([modernErrorsProcess])
4444
```
4545

46-
...
46+
Initializing process error handler.
4747

4848
```js
4949
AnyError.logProcess()
5050
```
5151

5252
# Install
5353

54-
Production code (e.g. a server) can install this either as a production or
55-
development dependency:
54+
Production code (e.g. a server) can install this either as a production or as a
55+
development dependency.
5656

5757
```bash
5858
npm install modern-errors-process
5959
```
6060

61-
However, libraries should install this as a development dependency:
61+
However, libraries should install this as a development dependency.
6262

6363
```bash
6464
npm install -D modern-errors-process
@@ -84,7 +84,7 @@ Plugin object to
8484

8585
_Return value_: `() => void`
8686

87-
Initializes `modern-errors-process`.
87+
Start handling process errors.
8888

8989
The return value restores Node.js default behavior.
9090

@@ -97,6 +97,19 @@ restore()
9797

9898
_Type_: `object`
9999

100+
[Options](#options) must be passed either to
101+
[`modernErrors()`](https://github.com/ehmicky/modern-errors#modernerrorsplugins-options).
102+
103+
```js
104+
export const AnyError = modernErrors(plugins, { process: { ...options } })
105+
```
106+
107+
Or to [`AnyError.logProcess()`](#anyerrorlogprocess).
108+
109+
```js
110+
AnyError.logProcess(...args, { ...options })
111+
```
112+
100113
### exit
101114

102115
_Type_: `boolean`
@@ -132,58 +145,14 @@ message.
132145

133146
#### event
134147

135-
_Type_: `string`
148+
_Type_: `Event`
136149

137150
Process event name among:
138151
[`'uncaughtException'`](https://nodejs.org/api/process.html#process_event_uncaughtexception),
139152
[`'unhandledRejection'`](https://nodejs.org/api/process.html#process_event_unhandledrejection),
140153
[`'rejectionHandled'`](https://nodejs.org/api/process.html#process_event_rejectionhandled),
141154
[`'warning'`](https://nodejs.org/api/process.html#process_event_warning).
142155

143-
## Configuration
144-
145-
[Options](#options) can apply to (in priority order):
146-
147-
- Any error: second argument to
148-
[`modernErrors()`](https://github.com/ehmicky/modern-errors#modernerrorsplugins-options)
149-
150-
```js
151-
export const AnyError = modernErrors(plugins, { process: { ...options } })
152-
```
153-
154-
- Any error of multiple classes: using
155-
[`ErrorClass.subclass()`](https://github.com/ehmicky/modern-errors#anyerrorsubclassname-options)
156-
157-
```js
158-
export const SharedError = AnyError.subclass('SharedError', {
159-
process: { ...options },
160-
})
161-
162-
export const InputError = SharedError.subclass('InputError')
163-
export const AuthError = SharedError.subclass('AuthError')
164-
```
165-
166-
- Any error of a specific class: second argument to
167-
[`AnyError.subclass()`](https://github.com/ehmicky/modern-errors#anyerrorsubclassname-options)
168-
169-
```js
170-
export const InputError = AnyError.subclass('InputError', {
171-
process: { ...options },
172-
})
173-
```
174-
175-
- A specific error: second argument to the error's constructor
176-
177-
```js
178-
throw new InputError('...', { process: { ...options } })
179-
```
180-
181-
- A specific [`AnyError.logProcess()`](#anyerrorlogprocess) call
182-
183-
```js
184-
AnyError.logProcess(...args, { ...options })
185-
```
186-
187156
# Related projects
188157

189158
- [`log-process-errors`](https://github.com/ehmicky/log-process-errors): Show

0 commit comments

Comments
 (0)