File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export interface FeathersErrorJSON {
88}
99
1010export type DynamicError = Error & { [ key : string ] : any }
11- export type ErrorMessage = string | DynamicError | { [ key : string ] : any } | any [ ]
11+ export type ErrorMessage = null | string | DynamicError | { [ key : string ] : any } | any [ ]
1212
1313interface ErrorProperties extends Omit < FeathersErrorJSON , 'message' > {
1414 type : string
@@ -33,7 +33,7 @@ export class FeathersError extends Error {
3333 if ( Array . isArray ( _data ) ) {
3434 properties . data = _data
3535 } else if ( typeof err === 'object' || _data !== undefined ) {
36- const { message, errors, ...rest } = typeof err === 'object' ? err : _data
36+ const { message, errors, ...rest } = err !== null && typeof err === 'object' ? err : _data
3737
3838 msg = message || msg
3939 properties . errors = errors
Original file line number Diff line number Diff line change @@ -345,6 +345,11 @@ describe('@feathersjs/errors', () => {
345345 assert . deepStrictEqual ( error . data , [ { hello : 'world' } ] )
346346 } )
347347
348+ it ( 'can be instantiated with `null` (#2789)' , ( ) => {
349+ const err = new errors . BadRequest ( null , { } )
350+ assert . strictEqual ( err . message , 'Error' )
351+ } )
352+
348353 it ( 'has proper stack trace (#78)' , ( ) => {
349354 try {
350355 throw new errors . NotFound ( 'Not the error you are looking for' )
You can’t perform that action at this time.
0 commit comments