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

Function writeError

ark/schema/shared/errors.ts:964–982  ·  view source on GitHub ↗
(
	error: ArkError,
	config: ResolvedConfig,
	locale: Locale.Resolved
)

Source from the content-addressed store, hash-verified

962 writtenLocales.get(error) ?? configOf(error).locale
963
964const writeError = (
965 error: ArkError,
966 config: ResolvedConfig,
967 locale: Locale.Resolved
968): void => {
969 if (locale !== config.locale) writtenLocales.set(error, locale)
970 const code = error.code
971 if (code === "union") {
972 writeAtPaths(error, config, locale)
973 writeRelative(error, config, locale)
974 return
975 }
976 // any other holds no errors and no bases, so it's written once at its path:
977 // what writeAtPaths does for it, without reading its code again for each
978 // question only a union answers
979 error.propString ??= stringifyPath(error.path)
980 if (renderer && locale !== renderer.en) renderer.write(error, config, locale)
981 else writeText(error, config, locale, code)
982}
983
984// the line of a union that lists its errors' whole paths, held as a
985// standalone validator's issue holds it, where another copy of arktype reads

Callers 5

issuesMethod · 0.85
_firstGroupedMethod · 0.85
invalidErrorFunction · 0.85
writeAtPathsFunction · 0.85
writtenInFunction · 0.85

Calls 6

stringifyPathFunction · 0.90
writeAtPathsFunction · 0.85
writeRelativeFunction · 0.85
writeTextFunction · 0.70
setMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected