@@ -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'
2929import 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
8587Plugin 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
178171export 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
186180throw new AuthError (' ...' , { http: { ... options } })
0 commit comments