RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.2, Nov 26, 2026 ·

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
    • Session Engine
    • Execution Requests
    • Workspace State
    • Variable Inspection
    • Workspace Replay
    • Interaction & Streams
    • Host Integration
    • Execution
    • Async Execution
    • Errors & Diagnostics
    • Parallel Execution
    • Remote Execution
Docs>Runtime>Sessions and Execution

Errors & Diagnostics

RunMat separates request setup and compile-stage failures from runtime failures. Source resolution, parser, HIR, and bytecode compilation failures leave execute_request as Err(RunError). Runtime failures raised after bytecode execution begins use RuntimeError; the session captures them as diagnostics in ExecutionOutcome so hosts can still receive streams, warnings, figures, and other execution metadata.

Error Flow

Loading diagram...

Compile-stage failures do not enter MATLAB try/catch; they occur before bytecode execution. try/catch handles RuntimeError values raised during VM or JIT execution.

Static analysis can identify a failing value operation, such as multiplication with incompatible matrix dimensions. runmat check and editor diagnostics still report that error. Executable compilation retains the operation's runtime check rather than rejecting the entire program: an enclosing try/catch, including one in a caller, can handle the failure. Syntax errors and failures that prevent lowering or compilation remain compile-stage errors.

RunError

runmat-core exposes four failure stages through RunError:

VariantSource
SyntaxParser errors from source text.
SemanticHIR lowering, validation, name resolution, and semantic checks.
CompileVM bytecode compilation and lowering failures after semantic analysis.
RuntimeRuntimeError values used for runtime failures and runtime diagnostics.

Telemetry and host error payloads keep the stage so callers can distinguish invalid source from a runtime exception. Runtime failures that occur inside an assembled execution outcome use the same RuntimeError structure, but they are carried through ExecutionOutcome::diagnostics.

RuntimeError

RuntimeError is the shared runtime failure type re-exported by runmat-runtime. It carries:

FieldMeaning
messageHuman-readable error text.
identifierStable MATLAB-style identifier such as RunMat:UndefinedFunction.
spanOptional source span for diagnostics.
sourceOptional wrapped Rust error.
context.builtinBuiltin that produced the error, when known.
context.phaseRuntime phase, when known.
context.task_idAsync task identifier, when relevant.
context.call_stack / call_framesHuman-readable call stack or structured call frames.
context.call_frames_elidedNumber of hidden call frames when the stack is truncated.

The builder API adds identifiers, builtin names, phases, spans, source errors, task IDs, and call-stack context. Diagnostic formatting can include source snippets, caret spans, builtin/phase/task metadata, and call-stack lines.

Namespace And Call Stack Normalization

The session sets the active HIR and VM error namespace before execution. Runtime identifiers are normalized through that namespace before the host sees them, preserving the suffix while replacing the configured prefix when needed.

If a runtime error leaves the VM, the session populates call-stack text from VM call frames and the SourcePool. This is where function names, source names, line/column positions, and elided-frame counts become host-visible diagnostic context.

MATLAB Exceptions

MException is represented as a runtime value with an identifier, message, and stack. The VM converts caught RuntimeError values into MException values when it redirects control to a catch block. Dot access and getfield return character vectors for identifier and message, so expressions such as ['Failed: ' e.message] concatenate text. An empty identifier or message is a 0-by-0 character array. RunMat currently exposes stack as a cell array of frame descriptions, rather than MATLAB's stack structure array.

try/catch compiles to bytecode-level exception routing:

Bytecode stateRole
EnterTry(catch_pc, catch_var)Pushes a catch target onto the interpreter try_stack.
PopTryRemoves the target when the protected region exits normally.
redirect_exception_to_catchConverts RuntimeError to MException, stores the optional catch variable, establishes the active lexical catch authority, and jumps to the catch block.

rethrow(e) preserves the original runtime failure, including its source location and call frames, when e was caught from execution. In RunMat compatibility mode, rethrow() without an argument uses the currently active lexical catch, including in a callback invoked by that catch. After the catch exits, the shorthand cannot reuse its exception.

Diagnostics Builtins

The diagnostics builtins are ordinary runtime builtins that raise RuntimeError or record warnings.

BuiltinBehavior
errorRaises a runtime error from a message, identifier/message pair, formatted message, MException, or message struct.
assertRaises an assertion error when the condition is false. Real numeric, logical, and character arrays pass only when nonempty and all elements are nonzero; NaN cannot convert to logical. GPU values are gathered before evaluation.
warningRecords or emits a warning, controls warning state, queries status, and can promote warnings to errors.

Unqualified identifiers are normalized with a RunMat: prefix. Message structs can use identifier or messageid for the code and message or msg for the text.

Warnings are stored separately from errors. The session drains the warning store after execution and appends warning diagnostics to ExecutionOutcome::diagnostics. A warning promoted to error is returned as a RuntimeError.

WASM Error Payloads

The WASM bindings serialize errors into structured JavaScript payloads instead of plain strings. A payload includes:

FieldMeaning
kindsyntax, semantic, compile, or runtime.
messageHuman-readable message.
identifierStable error identifier, when available.
diagnosticFormatted diagnostic text.
spanStart, end, line, and column when source span information exists.
callstackRuntime call-stack lines or frame function names.
callstackElidedNumber of elided runtime frames.

Initialization failures are separate JavaScript Error values with codes such as InvalidOptions, FilesystemProvider, and SessionCreation.

Boundaries

Runtime errors are data-rich, but not every failure has a source span or call stack. Parser, HIR, and compiler errors are often attached to source spans before execution begins. Runtime builtin errors may only know the builtin name and message unless the VM call site or session source pool can attach more context.

Host integrations should display identifiers and messages prominently, preserve structured fields for programmatic handling, and include formatted diagnostics when a text console view is appropriate.

On this page
  • Error Flow
  • RunError
  • RuntimeError
  • Namespace And Call Stack Normalization
  • MATLAB Exceptions
  • Diagnostics Builtins
  • WASM Error Payloads
  • Boundaries