UNPKG

prisma-error-formatter

Version:

A flexible and customizable Prisma error formatter to simplify and unify error handling in Prisma Client applications.

16 lines (15 loc) 577 B
"use strict"; 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, }, ]; }