{"record":{"id":"779a49704dfa3171","repo":"can1357/oh-my-pi","slug":"traversalerror-thrown-by-omperrors-throw-with-me","errorCode":null,"errorMessage":"TraversalError thrown by OmpErrors.throw() with message equal to errors summary","messagePattern":"TraversalError thrown by OmpErrors\\.throw\\(\\) with message equal to errors summary","errorType":"exception","errorClass":"TraversalError","httpStatus":null,"severity":"error","filePath":"packages/omptype/src/errors.ts","lineNumber":424,"sourceCode":"\t\t\t\tentry =>\n\t\t\t\t\tObject.is(entry.data, entries[0].data) &&\n\t\t\t\t\tentry.path.length === entries[0].path.length &&\n\t\t\t\t\tentry.path.every((key, index) => key === entries[0].path[index]),\n\t\t\t)\n\t\t) {\n\t\t\tconst at = formatPath(entries[0].path);\n\t\t\tconst actual = typeof entries[0].data === \"string\" ? JSON.stringify(entries[0].data) : String(entries[0].data);\n\t\t\treturn `${at}${at === \"\" ? \"\" : \" \"}(${actual}) must be...\\n${entries.map(entry => `  ◦ ${entry.expected}`).join(\"\\n\")}`;\n\t\t}\n\t\treturn entries.map(error => error.message).join(this.#separator);\n\t}\n\n\ttoString(): string {\n\t\treturn this.summary;\n\t}\n\n\tthrow(): never {\n\t\tthrow new TraversalError(this);\n\t}\n}\n\n/** Error thrown by `Type.assert` on invalid input. */\nexport class TraversalError extends Error {\n\tconstructor(readonly errors: OmpErrors) {\n\t\tsuper(errors.summary);\n\t\tthis.name = \"TraversalError\";\n\t}\n}\n\n/**\n * Definition/usage error thrown while building a schema — malformed string\n * DSL, unsupported composition, or an illegal builder call. Distinct from\n * validation failures, which are returned as {@link OmpErrors}.\n */\nexport class OmpTypeError extends Error {\n\tconstructor(message: string) {","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/omptype/src/errors.ts#L406-L442","documentation":"`Type.assert` validation failures are aggregated into an `OmpErrors` object; calling `.throw()` wraps it in a `TraversalError`. The error's message equals the human-readable summary of all traversal errors found during validation. Catching it gives you the full `errors` object for structured inspection of every failed check.","triggerScenarios":"Calling `type.assert(value)` (or `.throw()` on an `OmpErrors` instance) when the validated value fails one or more type constraints.","commonSituations":"Validating untrusted JSON input (API payloads, config files) against an ArkType-compatible schema; type changes after schema updates; partially migrated data shapes.","solutions":["Fix the data so it satisfies the type; read `error.summary` for the exact failing paths.","Catch `TraversalError` and inspect `err.errors` for per-path diagnostics.","Use `type.allows(value)` or a `try` around `assert` when input validity is uncertain."],"exampleFix":"// before\ntype.assert(input); // throws TraversalError\n// after\nif (!type.allows(input)) {\n  const err = type(input); // inspect per-key errors\n  throw new Error(`bad input: ${err.summary}`);\n}","handlingStrategy":"try-catch","validationCode":"const result = type(value); // returns errors instead of throwing\nif (result instanceof type.constructor // ArkType: truthy result means valid\n  ) {} else { console.log(result.summary); }","typeGuard":"function isValid(v: unknown): boolean { return type.allows(v); }","tryCatchPattern":"try {\n  type.assert(value);\n} catch (err) {\n  if (err instanceof TraversalError) {\n    console.error(err.errors.summary); // per-path diagnostics\n  } else throw err;\n}","preventionTips":["Prefer `type(value)` or `type.allows(value)` over `assert` when input may be invalid.","Validate all external input (API, files, env) at the boundary before use.","Keep schemas and data shapes in sync; add tests for schema changes."],"tags":["validation","assert","type-error"],"backgroundTag":"schema-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}