1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-22 02:31:36 +02:00

🎨 proper error message body parser

This commit is contained in:
Flam3rboy 2021-04-06 04:05:46 +02:00
parent d700e4c8fa
commit 4f67c2c86e

View File

@ -148,8 +148,11 @@ export function instanceOf(
}) })
); );
} }
if (value instanceof type) return true; try {
throw new FieldError("BASE_TYPE_CLASS", req.t("common:field.BASE_TYPE_CLASS", { type })); if (value instanceof type) return true;
} catch (error) {
throw new FieldError("BASE_TYPE_CLASS", req.t("common:field.BASE_TYPE_CLASS", { type }));
}
} }
if (typeof value !== "object") throw new FieldError("BASE_TYPE_OBJECT", req.t("common:field.BASE_TYPE_OBJECT")); if (typeof value !== "object") throw new FieldError("BASE_TYPE_OBJECT", req.t("common:field.BASE_TYPE_OBJECT"));