A wrong AJV schema used in validation will throw an error with an undefined message.
Check the createError method.
@konzz what is AJV?
It is the validtion library we use.
handleError needs to correctly handle AJV validations.
so basically the problem we have is that we are destructuring the Errors.
const myError = new Error('an error message');
const destructuredError = {...myError, code: 500};
console.log(destructuredError)
// {code: 500}
seems like if its an Error object we should just return it instead of destructure it, i think we did this to properly parse ajv validation errors actually, breaking all other errors that are Error instance.
we should take care of all different errors and test it properly, Error, AJVValidation error and our own error object for starters.