BAML Error Types
BAML provides a set of error classes for handling different error scenarios when working with LLMs. Each error type is designed to handle specific failure cases in the BAML runtime.
Error Class Hierarchy
All BAML errors extend the base JavaScript Error
class and include a literal type
field for type identification.
Error Types
BamlValidationError
Thrown when BAML fails to parse or validate LLM output. Contains the original prompt and raw output for debugging.
BamlClientFinishReasonError
Thrown when an LLM terminates with a disallowed finish reason. Includes the original prompt and partial output received before termination.
Type Guards
All BAML errors can be identified using TypeScript’s instanceof
operator:
Common Properties
All BAML error classes include:
Literal type identifier specific to each error class.
Human-readable error message describing the failure.
For detailed information about each error type, refer to their individual reference pages.