errors

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errors provides error types for the message gateway.

This package defines structured error types that provide:

  • Provider identification
  • HTTP status codes (when applicable)
  • Error wrapping for errors.Is/As support

Error Types

  • ProviderError: Errors from message providers (API failures, rate limits)
  • ConfigError: Configuration validation errors
  • ProviderNotFoundError: Requested provider doesn't exist

Usage

if err != nil {
    var provErr *errors.ProviderError
    if errors.As(err, &provErr) {
        log.Printf("Provider %s failed: %s", provErr.Provider, provErr.Message)
    }
}

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoRecipients indicates no recipients were specified
	ErrNoRecipients = errors.New("no recipients specified")

	// ErrNoFromAddress indicates no sender address was specified
	ErrNoFromAddress = errors.New("no from address specified")

	// ErrNoDefaultProvider indicates no default provider is configured
	ErrNoDefaultProvider = errors.New("no default provider configured")
)

Sentinel errors for common failure cases

Functions

This section is empty.

Types

type ConfigError

type ConfigError struct {
	Provider string // Provider name
	Field    string // Configuration field with the issue
	Message  string // Error description
	Err      error  // Underlying error (optional)
}

ConfigError represents a configuration error

func NewConfigError

func NewConfigError(provider, field, message string) *ConfigError

NewConfigError creates a new ConfigError

func NewConfigErrorWithCause

func NewConfigErrorWithCause(provider, field, message string, err error) *ConfigError

NewConfigErrorWithCause creates a ConfigError wrapping an underlying error

func (*ConfigError) Error

func (e *ConfigError) Error() string

Error implements the error interface

func (*ConfigError) Unwrap

func (e *ConfigError) Unwrap() error

Unwrap returns the underlying error for errors.Is/As support

type ProviderError

type ProviderError struct {
	Provider   string // Provider name (e.g., "mailgun")
	StatusCode int    // HTTP status code if applicable
	Message    string // Human-readable error message
	Err        error  // Underlying error
}

ProviderError represents an error from a message provider

func NewProviderError

func NewProviderError(provider, message string, statusCode int, err error) *ProviderError

NewProviderError creates a new ProviderError

func (*ProviderError) Error

func (e *ProviderError) Error() string

Error implements the error interface

func (*ProviderError) Unwrap

func (e *ProviderError) Unwrap() error

Unwrap returns the underlying error for errors.Is/As support

type ProviderNotFoundError

type ProviderNotFoundError struct {
	ProviderType string // Type of provider (email, sms, push)
	ProviderName string // Name of the requested provider
}

ProviderNotFoundError indicates a requested provider doesn't exist

func NewProviderNotFoundError

func NewProviderNotFoundError(providerType, providerName string) *ProviderNotFoundError

NewProviderNotFoundError creates a new ProviderNotFoundError

func (*ProviderNotFoundError) Error

func (e *ProviderNotFoundError) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

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