{"record":{"id":"7894b2c02a0f1fa6","repo":"BoundaryML/baml","slug":"uncaught-throw-value","errorCode":null,"errorMessage":"uncaught throw: {value:?}","messagePattern":"uncaught throw: (.+?)","errorType":"exception","errorClass":"VmError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_vm_types/src/errors.rs","lineNumber":437,"sourceCode":"            origin: VmUnwindOrigin::unresolved(source),\n        }\n    }\n\n    #[must_use]\n    pub const fn with_origin(mut self, origin: VmUnwindOrigin) -> Self {\n        self.origin = origin;\n        self\n    }\n}\n\n/// Any kind of virtual machine error.\n#[derive(Debug, Error, PartialEq, Clone)]\npub enum VmError {\n    /// Catchable (panics and error values) — internal signal for exception unwinding.\n    #[error(\"uncaught throw: {0:?}\")]\n    Thrown(VmThrown),\n    /// An exception that escaped all catch handlers, with captured stack trace.\n    #[error(\"uncaught throw: {value:?}\")]\n    ThrownUnhandled {\n        value: Value,\n        trace: Vec<StackFrame>,\n    },\n    /// Fatal VM errors\n    #[error(\"{0}\")]\n    InternalError(#[from] VmInternalError),\n    /// Fatal VM error with captured stack trace.\n    /// Produced by `exec()` wrapper from `InternalError`.\n    #[error(\"{}\", format_internal_error(source, trace))]\n    TracedInternalError {\n        source: VmInternalError,\n        trace: Vec<StackFrame>,\n    },\n}\n\nimpl VmError {\n    #[must_use]","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_vm_types/src/errors.rs#L419-L455","documentation":"VmError::ThrownUnhandled represents an exception that escaped all catch handlers in the BAML VM, carrying the thrown Value plus a captured stack trace (Vec<StackFrame>). Unlike the internal Thrown signal, this is the final, user-visible form: the throw propagated past every handler and terminated execution.","triggerScenarios":"A thrown error value traverses the entire call stack without any catch handler matching; the top-level BAML function itself throws; a panic raised in native code is not converted/handled by any frame.","commonSituations":"Running a BAML program where a deep helper throws (bad JSON parse, failed LLM call surfaced as a throw) and only the entry point sees the failure; missing catch blocks added when new fallible code paths were introduced.","solutions":["Read the attached stack trace to locate the innermost frame that threw.","Add a catch handler at the appropriate level for the thrown value type.","Handle the value at the host-language boundary if BAML-level handling is not desired.","Fix the root cause in the throwing frame (invalid input, failed client call, etc.)."],"exampleFix":"// before: unhandled deep throw terminates the run\nfn main() {\n  Deep.helper()\n}\n\n// after: handle at the call site\nfn main() {\n  let r = catch Deep.helper() {\n    case e => Log(\"failed: \", e); null\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match vm_result {\n    Err(BexError::ThrownUnhandled { value, trace }) => {\n        eprintln!(\"unhandled throw {:?} at:\", value);\n        for frame in &trace { eprintln!(\"  {}\", frame); }\n    }\n    other => other?,\n}","preventionTips":["Read the captured stack trace before adding handlers — fix the throwing frame when possible.","Ensure new fallible code paths ship with matching catch blocks.","Handle or convert throws at the host boundary for clean top-level reporting.","Keep catch-handler types aligned with the values your code throws."],"tags":["baml","vm","uncaught-exception","stack-trace"],"backgroundTag":"invalid-state-transition","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}