unacy / MaxDepthError
Class: MaxDepthError
Defined in: packages/core/src/errors.ts:103
Error thrown when BFS path-finding exceeds the maximum conversion depth.
Remarks
The maximum depth is currently fixed at 5 hops. This prevents the BFS from exploring excessively large graphs and guards against near-cycles (long paths that would be impractical for production use anyway).
If you hit this error, consider:
- Using
allow(A, Z)to cache the composed path once found, avoiding repeated BFS traversal. - Splitting a long dimension chain into domain-specific sub-registries.
- Registering a direct edge for the problematic pair.
Example
typescript
try {
registry.getConverter('A', 'F'); // requires 6-hop path
} catch (e) {
if (e instanceof MaxDepthError) {
console.error(`Path A→F exceeds max depth of ${e.maxDepth}`);
}
}Pitfalls
NEVER design a conversion graph that relies on paths longer than 5 hops — MaxDepthError is thrown at runtime and cannot be caught as a type error. Register intermediate direct edges or use allow() to cap the chain.
Extends
Constructors
Constructor
ts
new MaxDepthError(
from,
to,
maxDepth): MaxDepthError;Defined in: packages/core/src/errors.ts:108
Parameters
| Parameter | Type |
|---|---|
from | PropertyKey |
to | PropertyKey |
maxDepth | number |
Returns
MaxDepthError
Overrides
Properties
| Property | Modifier | Type | Inherited from | Defined in |
|---|---|---|---|---|
cause? | public | unknown | UnacyError.cause | node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24 |
from | readonly | PropertyKey | - | packages/core/src/errors.ts:104 |
maxDepth | readonly | number | - | packages/core/src/errors.ts:106 |
message | public | string | UnacyError.message | node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075 |
name | public | string | UnacyError.name | node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074 |
stack? | public | string | UnacyError.stack | node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
to | readonly | PropertyKey | - | packages/core/src/errors.ts:105 |