MCPcopy Create free account
hub / github.com/arktypeio/arktype / errorOfIssue

Function errorOfIssue

ark/schema/shared/errors.ts:255–278  ·  view source on GitHub ↗
(
	issue: ArkIssue & { message: string },
	prefix: array<PropertyKey>,
	config: ResolvedConfig
)

Source from the content-addressed store, hash-verified

253
254// keeps the text a standalone validator wrote; its actual describes its data
255export const errorOfIssue = (
256 issue: ArkIssue & { message: string },
257 prefix: array<PropertyKey>,
258 config: ResolvedConfig
259): ArkError => {
260 const message = issue.message ?? messageOf(issue)
261 const meta: ArkEnv.meta = { expected: issue.expected ?? message, message }
262 const error = stampError(
263 {
264 code: issue.code,
265 path: [...prefix, ...issue.path],
266 data: issue.data,
267 meta,
268 // a union's issue carries no branch errors
269 ...(issue.code === "union" && { errors: [] })
270 } as never,
271 config
272 )
273 // its line is the validator's, which wrote it as arktype would have
274 if (!isCustomIssue(issue)) templated.add(error)
275 if (!prefix.length && issue._l !== undefined) noteLine(error, issue._l)
276 if (issue._n !== undefined) labeledIssue(error, issue._n)
277 return error
278}
279
280const mergeErrors = (
281 errors: ArkErrors,

Callers 1

_mergeMethod · 0.85

Calls 6

messageOfFunction · 0.90
isCustomIssueFunction · 0.90
labeledIssueFunction · 0.90
stampErrorFunction · 0.85
noteLineFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected