prisma-error-formatter
Version:
A flexible and customizable Prisma error formatter for better error handling and user-friendly error messages in Prisma Client applications.
16 lines (15 loc) • 577 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatValidationError = formatValidationError;
function formatValidationError(exception) {
var _a;
const raw = exception.message || "Invalid query or DB error.";
const match = raw.match(/Argument `(\w+)` is missing/);
const field = (_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : "query";
return [
{
path: field,
message: match ? `Argument \`${field}\` is missing.` : raw,
},
];
}