Skip to content

Commit 243bbad

Browse files
committed
Update README
1 parent f51cc5c commit 243bbad

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

README.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ details") to use in an HTTP response.
2525
[`modern-errors`](https://github.com/ehmicky/modern-errors).
2626

2727
```js
28-
import modernErrors from 'modern-errors'
28+
import ModernError from 'modern-errors'
2929
import modernErrorsHttp from 'modern-errors-http'
3030

31-
export const BaseError = modernErrors([modernErrorsHttp])
31+
export const BaseError = ModernError.subclass('BaseError', {
32+
plugins: [modernErrorsHttp],
33+
})
3234
```
3335

3436
[Configuring](#configuration) error fields.
@@ -83,7 +85,7 @@ not `require()`.
8385
_Type_: `Plugin`
8486

8587
Plugin object to
86-
[pass to `modernErrors()`](https://github.com/ehmicky/modern-errors#adding-plugins).
88+
[pass to the `plugins` option of `ErrorClass.subclass()`](https://github.com/ehmicky/modern-errors#adding-plugins).
8789

8890
## error.httpResponse()
8991

@@ -153,34 +155,26 @@ set to an empty object.
153155
[Options](#options) can apply to (in priority order):
154156

155157
- Any error: second argument to
156-
[`modernErrors()`](https://github.com/ehmicky/modern-errors#modernerrorsplugins-options)
157-
158-
```js
159-
export const BaseError = modernErrors(plugins, { http: { ...options } })
160-
```
161-
162-
- Any error of multiple classes: using
163-
[`ErrorClass.subclass()`](https://github.com/ehmicky/modern-errors#baseerrorsubclassname-options)
158+
[`ModernError.subclass()`](https://github.com/ehmicky/modern-errors#options-1)
164159

165160
```js
166-
export const SharedError = BaseError.subclass('SharedError', {
161+
export const BaseError = ModernError.subclass('BaseError', {
162+
plugins: [modernErrorsHttp],
167163
http: { ...options },
168164
})
169-
170-
export const AuthError = SharedError.subclass('AuthError')
171-
export const InputError = SharedError.subclass('InputError')
172165
```
173166

174-
- Any error of a specific class: second argument to
175-
[`BaseError.subclass()`](https://github.com/ehmicky/modern-errors#baseerrorsubclassname-options)
167+
- Any error of a specific class (and its subclasses): second argument to
168+
[`ErrorClass.subclass()`](https://github.com/ehmicky/modern-errors#options-1)
176169

177170
```js
178171
export const AuthError = BaseError.subclass('AuthError', {
179172
http: { ...options },
180173
})
181174
```
182175

183-
- A specific error: second argument to the error's constructor
176+
- A specific error: second argument to
177+
[`new ErrorClass()`](https://github.com/ehmicky/modern-errors#options-3)
184178

185179
```js
186180
throw new AuthError('...', { http: { ...options } })

0 commit comments

Comments
 (0)