BamlAbortError
Overview
BamlAbortError
is thrown when a BAML function call is cancelled via an abort controller. This error indicates that the operation was intentionally stopped rather than failing due to an actual error condition.
Class Definition
TypeScript
Python
Go
Ruby
Properties
message
Type: string
Description of why the operation was aborted. This is typically a generic message like “Operation aborted” unless a specific message was provided during cancellation.
reason
Type: any
(TypeScript/Python) / interface{}
(Go) / Object
(Ruby)
Optional additional context about the cancellation. This can be any value provided when calling the abort()
method.
name
Type: string
Always returns "BamlAbortError"
for easy error type identification.
Error Detection
TypeScript
Python
Go
Ruby
Common Patterns
Distinguishing Cancellation Types
Cleanup After Cancellation
Retry Logic with Abort Errors
Integration with Streaming
When streaming operations are cancelled, the error behavior differs slightly:
TypeScript
Python
Best Practices
1. Always Handle Abort Errors Explicitly
2. Provide Meaningful Cancellation Reasons
3. Don’t Retry Cancelled Operations
Related Documentation
- AbortController - API reference for abort controllers
- Error Overview - Complete error hierarchy
- User Guide: Abort Controllers - Learn how to use abort controllers
- Error Handling Guide - General error handling patterns