Skip to content

Commit

Permalink
Incorporate explanation from @colinhacks into message doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronhipple committed Feb 4, 2025
1 parent c2750a0 commit 82936b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion deno/lib/ZodError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ export class ZodError<T = any> extends Error {
}

/**
* message returns the .issues field as a pretty-printed JSON string, NOT necessarily a human-readable message.
* message is a JSON.stringified issues array. This is an intentional decision
* to make the message property as informative as possible for logging, etc.
* You should use .issues to retrieve granular error information rather than
* JSON.parse(err.message).
*/
override get message() {
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
Expand Down
5 changes: 4 additions & 1 deletion src/ZodError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ export class ZodError<T = any> extends Error {
}

/**
* message returns the .issues field as a pretty-printed JSON string, NOT necessarily a human-readable message.
* message is a JSON.stringified issues array. This is an intentional decision
* to make the message property as informative as possible for logging, etc.
* You should use .issues to retrieve granular error information rather than
* JSON.parse(err.message).
*/
override get message() {
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
Expand Down

0 comments on commit 82936b2

Please sign in to comment.