/** Base class for every error the chart-rule evaluator can throw. */ export class ChartRuleError extends Error {} /** * A node whose `kind` is not in the vocabulary. The caller catches this and * shows the setting as "configured in code", read-only. */ export class UnknownNodeError extends ChartRuleError { constructor(public readonly kind?: string) { super(`Unknown chart-rule node: ${kind ?? '(missing kind)'}`); this.name = 'UnknownNodeError'; } } /** A node evaluated to the wrong type of value (e.g. comparing non-numbers). */ export class RuleTypeError extends ChartRuleError { constructor(message: string) { super(message); this.name = 'RuleTypeError'; } } /** * A structurally invalid node in a deserialized value: not an object, no string * `kind`, or a `literal` without a scalar `value`. Distinct from * `UnknownNodeError` (a well-formed node whose `kind` is simply not in the * vocabulary — the intentional escape hatch). Like the others it is a * `ChartRuleError`, so a caller reading an untrusted rule catches it instead of * a native `TypeError` (or, worse, an `undefined` slipping through silently). */ export class MalformedRuleError extends ChartRuleError { constructor(message: string) { super(message); this.name = 'MalformedRuleError'; } } /** @deprecated v1 is non-recursive. Retained for source compatibility. */ export class RuleDepthError extends ChartRuleError { constructor(maxDepth: number) { super(`chart rule nested deeper than ${maxDepth} levels`); this.name = 'RuleDepthError'; } }