I'm migrating the feathers-authentication-management package to dove, and I encounter an error in the... error package :-).
We have a call to BadRequest with potentially no error message in first param (see https://github.com/feathersjs-ecosystem/feathers-authentication-management/blob/master/src/methods/check-unique.ts#L74-L77).
In crow implementation, if we make the call
const err = new BadRequest(null, data)
// this will equivalent to
const err = FeathersError(null, 'BadRequest', 400, 'bad-request', data);
err will be like
{
type: 'FeathersError',
name: 'BadRequest',
message: 'Error', // by default, with null value in first param, the "Error" string is set
code: 400,
className: 'bad-request',
...
}
In dove implementation, with the same call - the BadRequest one,
this will break at #L35 as typeof null === 'object' is true.
Code will try to destructure null in { message, errors, ...rest }.
Another interesting thing is that constructor of errors like, eg, BadRequest takes 2 optional params message?: ErrorMessage, data?: any, but the FeathersError constructor want mandatory params : err and _data aren't optional.
This use case allow feathers-authentication-management to still create BadRequest errors with an err null.
Is this use case still accepted ?
Could we fix the previous implementation ?
I fix temporary the package by updating the #L36 :
const { message, errors, ...rest } = typeof err === 'object' && err !== null ? err : _data;
If needed, I can submit a PR with fix on typing (FeathersError constructor with err: ErrorMessage | null) and tests proving new BadRequest(null, ...) work.
I'm migrating the
feathers-authentication-managementpackage to dove, and I encounter an error in the...errorpackage :-).We have a call to
BadRequestwith potentially no error message in first param (see https://github.com/feathersjs-ecosystem/feathers-authentication-management/blob/master/src/methods/check-unique.ts#L74-L77).In crow implementation, if we make the call
errwill be likeIn dove implementation, with the same call - the
BadRequestone,this will break at #L35 as
typeof null === 'object'istrue.Code will try to destructure
nullin{ message, errors, ...rest }.Another interesting thing is that constructor of errors like, eg,
BadRequesttakes 2 optional paramsmessage?: ErrorMessage, data?: any, but theFeathersErrorconstructor want mandatory params :errand_dataaren't optional.This use case allow
feathers-authentication-managementto still createBadRequesterrors with anerrnull.Is this use case still accepted ?
Could we fix the previous implementation ?
I fix temporary the package by updating the #L36 :
If needed, I can submit a PR with fix on typing (FeathersError constructor with
err: ErrorMessage | null) and tests provingnew BadRequest(null, ...)work.