{"record":{"id":"dbffd7135e114f9f","repo":"BoundaryML/baml","slug":"exposederror-aborterror-detailed-message","errorCode":null,"errorMessage":"ExposedError::AbortError { detailed_message }","messagePattern":"ExposedError::AbortError (.+?)","errorType":"exception","errorClass":"ExposedError","httpStatus":null,"severity":"warning","filePath":"engine/baml-runtime/src/types/response.rs","lineNumber":156,"sourceCode":"                            _ => Err(anyhow::anyhow!(\n                                crate::errors::ExposedError::ClientHttpError {\n                                    client_name: err.client.clone(),\n                                    message: err.message.clone(),\n                                    status_code: err.code.clone(),\n                                    detailed_message: err.message.clone(),\n                                    raw_response: err.raw_response.clone(),\n                                }\n                            )),\n                        }\n                    }\n                    LLMResponse::UserFailure(message) => {\n                        Err(anyhow::anyhow!(\"User Failure: {message}.\\nPlease report this error to our team with BAML_LOG=info enabled so we can catch this error earlier and improve your development experience.\"))\n                    }\n                    LLMResponse::InternalFailure(message) => {\n                        Err(anyhow::anyhow!(\"Internal Failure: {message}.\\nThis should not happen - please report this error to our team with BAML_LOG=info enabled so we can catch this error earlier and improve your development experience.\"))\n                    }\n                    LLMResponse::Cancelled(message) => {\n                        Err(anyhow::anyhow!(crate::errors::ExposedError::AbortError {\n                            detailed_message: message.clone(),\n                        }))\n                    }\n                    LLMResponse::Success(_) => {\n                        Err(anyhow::anyhow!(\"This should never happen - Please report this error to our team with BAML_LOG=info enabled so we can improve this error message\"))\n                    }\n                };\n        };\n\n        result\n    }\n\n    fn format_last_error_with_details(&self, last_error: &anyhow::Error) -> ExposedError {\n        let detailed_message = self.create_detailed_message();\n\n        if let Some(exposed_error) = last_error.downcast_ref::<ExposedError>() {\n            return self.add_detailed_message_to_exposed(exposed_error.clone(), detailed_message);\n        }","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/types/response.rs#L138-L174","documentation":"When the chain's LLMResponse is Cancelled, result_with_constraints_content converts it to ExposedError::AbortError with the cancellation detail message. This indicates the function execution was aborted (e.g. via a cancellation handle) rather than completing or failing.","triggerScenarios":"The LLM call/stream was cancelled — user-initiated abort via the runtime's cancellation API, dropped futures, or client disconnects — and the result is then read.","commonSituations":"Web request cancelled by the client while streaming; explicit .cancel() calls; timeouts in the host application that abort the BAML future mid-flight.","solutions":["Treat AbortError as an expected control-flow signal and handle it separately from real failures.","Ensure callers do not read the result after cancelling the run.","If cancellations are unexpected, audit which component aborts the future (proxy timeouts, request shutdown hooks)."],"exampleFix":"// before\nlet result = baml_fn.run(ctx).await?; // AbortError if cancelled\n\n// after\nmatch baml_fn.run(ctx).await {\n    Ok(v) => Ok(v),\n    Err(e) if is_abort_error(&e) => Ok(default_value), // cancelled by caller\n    Err(e) => Err(e),\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match run_result {\n    Ok(v) => Ok(v),\n    Err(e) if e.to_string().contains(\"AbortError\") => Ok(default_value),\n    Err(e) => Err(e),\n}","preventionTips":["Never read chain results after cancelling the run","Distinguish client disconnects from real failures in API handlers","Audit proxy/server timeouts that abort in-flight BAML futures"],"tags":["cancellation","abort","async"],"backgroundTag":"operation-aborted","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}