errors

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errors defines standard error types used across llm-router services.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a requested resource does not exist
	ErrNotFound = errors.New("not found")

	// ErrAlreadyExists is returned when attempting to create a duplicate resource
	ErrAlreadyExists = errors.New("already exists")

	// ErrInvalidInput is returned when input validation fails
	ErrInvalidInput = errors.New("invalid input")

	// ErrUnauthorized is returned for authentication failures
	ErrUnauthorized = errors.New("unauthorized")

	// ErrForbidden is returned for authorization failures
	ErrForbidden = errors.New("forbidden")

	// ErrModelNotAllowed is returned when a token's rules forbid the requested model
	ErrModelNotAllowed = errors.New("model not allowed by token rules")

	// ErrProviderNotAllowed is returned when a token's rules forbid the requested provider
	ErrProviderNotAllowed = errors.New("provider not allowed by token rules")

	// ErrCredentialNotAllowed is returned when a token's rules forbid all credentials for a provider
	ErrCredentialNotAllowed = errors.New("no allowed credential available for provider")

	// ErrNoCredential is returned when no credential is available for a provider
	ErrNoCredential = errors.New("no credential available for provider")

	// ErrProviderNotFound is returned when no provider can handle a given ModelId
	ErrProviderNotFound = errors.New("provider not found for model")
	// ErrProviderDisabled is returned when the provider is switched off
	ErrProviderDisabled = errors.New("provider is disabled")

	// ErrModelDisabled is returned when an admin override disables the requested model
	ErrModelDisabled = errors.New("model is disabled by administrator")

	// ErrEndpointNotSupported is returned when the provider or model does
	// not serve the requested endpoint (e.g. audio/transcriptions)
	ErrEndpointNotSupported = errors.New("endpoint not supported")
)

Standard sentinel errors

Functions

func NewNotFoundError

func NewNotFoundError(resource, id string) error

NewNotFoundError creates a NotFoundError

func NewValidationError

func NewValidationError(field, message string) error

NewValidationError creates a ValidationError

Types

type NotFoundError

type NotFoundError struct {
	Resource string
	ID       string
}

NotFoundError wraps ErrNotFound with context about what was not found

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError wraps ErrInvalidInput with details about what failed validation

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL