mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-11 07:58:13 -05:00
23 lines
505 B
JavaScript
23 lines
505 B
JavaScript
export const Errors = {
|
|
ENTITY_NOT_FOUND: "entity not found",
|
|
INVALID_PAYLOAD: "invalid payload",
|
|
};
|
|
|
|
const errorValues = Object.values(Errors);
|
|
|
|
export function sanitizeErrorMessage(message) {
|
|
if (typeof message === "string" && errorValues.includes(message)) {
|
|
return message;
|
|
} else {
|
|
return "an unknown error has occurred";
|
|
}
|
|
}
|
|
|
|
export function mapErrorDetails(details) {
|
|
return details.map((item) => ({
|
|
message: item.message,
|
|
path: item.path,
|
|
type: item.type,
|
|
}));
|
|
}
|