feat: log document id in ValidationError cause, if present
This commit is contained in:
@@ -351,6 +351,7 @@ export const upsertRow = async <T extends Record<string, unknown> | TypeWithID>(
|
||||
throw error.code === '23505'
|
||||
? new ValidationError(
|
||||
{
|
||||
id,
|
||||
errors: [
|
||||
{
|
||||
field: adapter.fieldConstraints[tableName][error.constraint],
|
||||
|
||||
@@ -21,7 +21,12 @@ export class ValidationError extends APIError<{
|
||||
global?: string
|
||||
}> {
|
||||
constructor(
|
||||
results: { collection?: string; errors: ValidationFieldError[]; global?: string },
|
||||
results: {
|
||||
collection?: string
|
||||
errors: ValidationFieldError[]
|
||||
global?: string
|
||||
id?: number | string
|
||||
},
|
||||
t?: TFunction,
|
||||
) {
|
||||
const message = t
|
||||
|
||||
@@ -71,6 +71,7 @@ export const beforeChange = async <T extends JsonObject>({
|
||||
if (errors.length > 0) {
|
||||
throw new ValidationError(
|
||||
{
|
||||
id,
|
||||
collection: collection?.slug,
|
||||
errors,
|
||||
global: global?.slug,
|
||||
|
||||
Reference in New Issue
Block a user