BamlValidationError

The BamlValidationError class represents an error that occurs when BAML fails to parse or validate LLM output.

Type Definition

Type Definition
1class BamlValidationError extends Error {
2 type: 'BamlValidationError'
3 message: string
4 prompt: string
5 raw_output: string
6}

Properties

type
'BamlValidationError'

Literal type identifier for the error class.

message
string

Error message describing the specific validation failure.

prompt
string

The original prompt sent to the LLM.

raw_output
string

The raw output from the LLM that failed validation.

Type Guards

The error can be identified using TypeScript’s instanceof operator:

Type Check
1if (error instanceof BamlValidationError) {
2 // Handle validation error
3}
Built with