Exceptions
When BAML raises an exception, it will be an instance of a subclass of BamlError
. This allows you to catch all BAML-specific exceptions with a single except
block.
Import path
BamlError
Base class for all BAML exceptions.
BamlInvalidArgumentError
Subclass of BamlError
.
Raised when one or multiple arguments to a function are invalid.
BamlClientError
Subclass of BamlError
.
Raised when a client fails to return a valid response.
In the case of aggregate clients like fallback
or those with retry_policy
, only the last client’s error is raised.
BamlClientHttpError
Subclass of BamlClientError
.
Raised when the HTTP request made by a client fails with a non-200 status code.
BamlValidationError
Subclass of BamlError
.
Raised when BAML fails to parse a string from the LLM into the specified object.