unacy / CycleError
Class: CycleError
Defined in: packages/core/src/errors.ts:60
Error thrown when a cycle is detected during BFS path-finding.
Remarks
This error is thrown by findShortestPath when from === to (a unit being converted to itself). The registry's getConverter method re-throws CycleError rather than silently returning undefined.
Example
typescript
try {
registry.getConverter('Celsius', 'Celsius'); // same unit
} catch (e) {
if (e instanceof CycleError) {
console.error('Cycle in path:', e.path.join(' → '));
}
}Pitfalls
NEVER call registry.convert(value, 'X').to('X') — converting a unit to itself triggers cycle detection and throws CycleError at runtime.
Extends
Constructors
Constructor
ts
new CycleError(path): CycleError;Defined in: packages/core/src/errors.ts:63
Parameters
| Parameter | Type |
|---|---|
path | PropertyKey[] |
Returns
CycleError
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 |
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 |
path | readonly | PropertyKey[] | - | packages/core/src/errors.ts:61 |
stack? | public | string | UnacyError.stack | node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |