-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
title: "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 | ||
<CodeGroup> | ||
```python Python | ||
from baml_py.errors import BamlError | ||
``` | ||
|
||
```typescript TypeScript | ||
import { BamlError } from '@boundaryml/baml/errors' | ||
``` | ||
|
||
```ruby Ruby | ||
Not available yet | ||
``` | ||
</CodeGroup> | ||
|
||
|
||
## Exceptions | ||
|
||
### BamlError | ||
|
||
Base class for all BAML exceptions. | ||
|
||
<ResponseField | ||
name="error" | ||
type="string" | ||
> | ||
A human-readable error message. | ||
</ResponseField> | ||
|
||
### BamlParseError | ||
|
||
Subclass of `BamlError`. | ||
|
||
Raised when BAML fails to parse a response into a valid object. | ||
|
||
<ResponseField | ||
name="raw_llm_response" | ||
type="string" | ||
> | ||
The raw text from the LLM that failed to parse into the expected return type of a function. | ||
</ResponseField> | ||
|
||
### BamlLLMError | ||
|
||
Subclass of `BamlError`. | ||
|
||
Raised when the call to the LLM fails (only raises the last error). | ||
|
||
#### BamlRequestError | ||
|
||
Subclass of `BamlLLMError`. | ||
|
||
Raised when the request to the LLM fails with a non-200 status code. | ||
|
||
<ResponseField | ||
name="status_code" | ||
type="int" | ||
> | ||
The status code of the response. | ||
|
||
Common status codes are: | ||
|
||
- 400: Bad Request | ||
- 401: Unauthorized | ||
- 403: Forbidden | ||
- 404: Not Found | ||
- 429: Too Many Requests | ||
- 500: Internal Server Error | ||
</ResponseField> | ||
|
||
|
||
#### BamlInvalidResponseError | ||
|
||
Subclass of `BamlLLMError`. | ||
|
||
Raised when the response from the network request is not in the expected format. | ||
|
||
<ResponseField | ||
name="text" | ||
type="string" | ||
> | ||
The body of the response as a string. | ||
</ResponseField> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters