UNPKG

mathjslab

Version:

MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.

97 lines (96 loc) 2.64 kB
import type { CallFrame } from './CallFrame'; /** * # InterpreterError * * Base class for all evaluation-related errors. * * This class extends the native `Error` and adds optional * support for stack trace frames (`CallFrame[]`), enabling * MATLAB/Octave-like error reporting. * * ## Notes * * - `stackFrames` is optional to support legacy code paths * - Formatting is deferred to `toString()` / `format()` */ declare class InterpreterError extends Error { /** * Optional call stack snapshot. * * Top frame should be the first element. */ readonly stackFrames?: CallFrame[]; /** * Creates a new InterpreterError. * * @param message - Error message * @param stackFrames - Optional stack trace snapshot */ constructor(message: string, stackFrames?: CallFrame[]); /** * Formats the error message with optional stack trace. * * @returns Formatted error string */ format(): string; /** * Derives a human-readable name for a frame. */ protected getFrameName(frame: CallFrame): string; /** * Default string representation. */ toString(): string; } /** * # EvalError * * Represents a general runtime evaluation error. * * Examples: * - invalid operations * - domain errors */ declare class EvalError extends InterpreterError { constructor(message: string, stackFrames?: CallFrame[]); } /** * # ReferenceError * * Represents errors related to undefined identifiers. * * Examples: * - undefined variable * - undefined function */ declare class ReferenceError extends InterpreterError { constructor(message: string, stackFrames?: CallFrame[]); } /** * # UndefinedReferenceError * * Represents an unresolved identifier that may be registered as a * forward reference when the current evaluation mode allows it. */ declare class UndefinedReferenceError extends ReferenceError { readonly identifier: string; constructor(identifier: string, stackFrames?: CallFrame[]); } /** * # CircularReferenceError * * Represents a circular dependency between unresolved forward references. */ declare class CircularReferenceError extends InterpreterError { readonly chain: string[]; constructor(chain: string[], stackFrames?: CallFrame[]); } /** * # SyntaxError * * Represents syntax-related errors detected during parsing or preprocessing. */ declare class SyntaxError extends InterpreterError { constructor(message: string, stackFrames?: CallFrame[]); } export { InterpreterError, EvalError, ReferenceError, UndefinedReferenceError, CircularReferenceError, SyntaxError };