From bd34452a34e9d90c948b1e454d184085cd591871 Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Mon, 13 May 2024 15:28:48 -0400 Subject: [PATCH] Actions: include zod error in message for easier debugging (#11029) * refactor: embed zod object in error msg * chore: changeset --- .changeset/modern-donkeys-taste.md | 5 +++++ packages/astro/src/actions/runtime/virtual/shared.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/modern-donkeys-taste.md diff --git a/.changeset/modern-donkeys-taste.md b/.changeset/modern-donkeys-taste.md new file mode 100644 index 0000000000..0694e7169d --- /dev/null +++ b/.changeset/modern-donkeys-taste.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Actions: include validation error in thrown error message for debugging. diff --git a/packages/astro/src/actions/runtime/virtual/shared.ts b/packages/astro/src/actions/runtime/virtual/shared.ts index c51fcfa718..c6035702c1 100644 --- a/packages/astro/src/actions/runtime/virtual/shared.ts +++ b/packages/astro/src/actions/runtime/virtual/shared.ts @@ -110,7 +110,7 @@ export class ActionInputError extends ActionErro fields: z.ZodError['formErrors']['fieldErrors']; constructor(issues: z.ZodIssue[]) { - super({ message: 'Failed to validate', code: 'BAD_REQUEST' }); + super({ message: `Failed to validate: ${JSON.stringify(issues, null, 2)}`, code: 'BAD_REQUEST' }); this.issues = issues; this.fields = {}; for (const issue of issues) {