Unable to reference BamlValidationError in Python, referenced in docs
I'm unable to figure out how to reference (and therefore catch/handle) BamlValidationError in Python, which is referenced in the docs here: https://docs.boundaryml.com/ref/baml_client/errors/baml-validation-error
How can I catch this specific error in Python?
try:
return b.MyFunction("input")
except BamlValidationError as e:
# handling logic
Looking closer I do see that these docs only make reference to TypeScript, not Python. Is there a reason these specific error types are not available in Python? Are there any specific BAML error types available in Python (to avoid a generic except Exception as e:)?
Could you try
from baml_py.errors import BamlValidationError
That worked, thank you! For some reason VS Code was not able to find it to automatically add the import, not quite sure why. But this unblocks me, thank you 😄
Glad it helped! For me it also doesn’t’autofind with Ctrl+dot, unfortunately i had to manually find it.
Let us know if you figure it out💪
@htxryan Btw sometimes ctrl+dot issues are solved by restarting the language server, just in case it helps