Skip to main content

Overview

Error Handling Features:
  • Structured Errors - Consistent error format across all providers
  • Error Codes - Specific error codes for different failure types
  • Context Information - Detailed error context and debugging info
  • Automatic Fallbacks - Bifrost handles provider fallbacks automatically
  • Circuit Breaking - Available via plugins for advanced reliability
  • Provider Mapping - Provider-specific errors mapped to common format
Benefits:
  • Easier Debugging - Structured error information with context
  • Better Monitoring - Categorized errors for alerting and metrics
  • Built-in Reliability - Automatic fallbacks and recovery
  • Simple Integration - Handle errors without complex retry logic

Error Structure

BifrostError Schema

Go Package - BifrostError Structure
HTTP Transport - Error Response Format
HTTP Status Codes:

Basic Error Handling

Simple Error Handling

Go Package - Basic Error Handling
Note: Bifrost automatically handles fallbacks between providers, so you don’t need to implement manual fallback logic.
HTTP Transport - Basic Error Handling
Note: Bifrost HTTP transport automatically handles retries and fallbacks, so simple error handling is usually sufficient.

Common Error Types

Authentication Errors

Rate Limit Errors

Network Errors


Error Monitoring

Metrics and Alerting

Error Tracking Go Package - Error Metrics:
HTTP Transport - Prometheus Metrics: Bifrost automatically exposes error metrics at /metrics:

Best Practices

Error Handling Guidelines

Best Practices 1. Always Check for Bifrost Errors:
2. Log Errors with Context:
3. Monitor Error Patterns:
4. Don’t Implement Manual Fallbacks:

Next Steps

Tip: Bifrost handles complex error recovery automatically. Focus on understanding error types for monitoring and debugging rather than implementing retry logic.