feat: Use prettier-eslint to format code
This commit is contained in:
committed by
mrugesh mohapatra
parent
1ba67c4e2b
commit
b13e5fb41a
@@ -8,25 +8,20 @@ export function unwrapHandledError(err) {
|
||||
return err[_handledError] || {};
|
||||
}
|
||||
|
||||
export function wrapHandledError(err, {
|
||||
type,
|
||||
message,
|
||||
redirectTo,
|
||||
status = 200
|
||||
}) {
|
||||
export function wrapHandledError(
|
||||
err,
|
||||
{ type, message, redirectTo, status = 200 }
|
||||
) {
|
||||
err[_handledError] = { type, message, redirectTo, status };
|
||||
return err;
|
||||
}
|
||||
|
||||
// for use with express-validator error formatter
|
||||
export const createValidatorErrorFormatter = (type, redirectTo) =>
|
||||
({ msg }) => wrapHandledError(
|
||||
new Error(msg),
|
||||
{
|
||||
type,
|
||||
message: msg,
|
||||
redirectTo,
|
||||
// we default to 400 as these are malformed requests
|
||||
status: 400
|
||||
}
|
||||
);
|
||||
export const createValidatorErrorFormatter = (type, redirectTo) => ({ msg }) =>
|
||||
wrapHandledError(new Error(msg), {
|
||||
type,
|
||||
message: msg,
|
||||
redirectTo,
|
||||
// we default to 400 as these are malformed requests
|
||||
status: 400
|
||||
});
|
||||
|
Reference in New Issue
Block a user