Skip to main content
The Basalt SDK uses a consistent error handling pattern across all methods. This guide explains how to properly handle errors when using the SDK.

Error Pattern

All SDK methods return an object / tuple containing two properties:
  • value: The result of the operation when successful
  • error: An error object when the operation fails
This pattern allows you to easily check if an operation succeeded or failed before proceeding.

General Pattern

Error Types

The SDK can return different types of errors:
  • NotFoundError: When a requested resource doesn’t exist
  • ValidationError: When the provided parameters are invalid
  • AuthenticationError: When there’s an issue with authentication
  • NetworkError: When there’s a problem with the network connection
  • ServerError: When the server encounters an issue
  • UnknownError: For unexpected errors

Examples

Getting a Prompt

Listing Prompts

Describing a Prompt