errors

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errors provides a centralized error handling system for the azctx application. It defines custom error types and error wrapping functions to provide consistent error handling and reporting across the application.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrFileDoesNotExist is returned when attempting to access a non-existent file
	ErrFileDoesNotExist = errors.New("file does not exist")
	// ErrFetchingHomePath is returned when unable to determine the user's home directory
	ErrFetchingHomePath = errors.New("could not fetch home directory")
	// ErrPathIsEmpty is returned when a required file path is empty
	ErrPathIsEmpty = errors.New("path is empty")

	// ErrReadingConfiguration wraps errors that occur while reading configuration files
	ErrReadingConfiguration = func(err error) error {
		return fmt.Errorf("error reading configuration: %w", err)
	}

	// ErrNoPreviousContext is returned when attempting to switch to a previous context that doesn't exist
	ErrNoPreviousContext = errors.New("no previous context recorded yet; pick a subscription with azctx first")

	// ErrSubscriptionNotFound is returned when a requested subscription cannot be found
	ErrSubscriptionNotFound = errors.New("subscription not found")

	// ErrFileOperation wraps errors that occur during file operations with context about the operation
	ErrFileOperation = func(op string, err error) error {
		return fmt.Errorf("error %s file: %w", op, err)
	}

	// ErrOperation wraps generic operation errors with context about the operation
	ErrOperation = func(op string, err error) error {
		return fmt.Errorf("error during %s: %w", op, err)
	}

	// ErrSelectingSubscription wraps errors that occur during subscription selection
	ErrSelectingSubscription = func(err error) error {
		return fmt.Errorf("error selecting subscription: %w", err)
	}

	// ErrSettingPreviousContext wraps errors that occur while setting the previous context
	ErrSettingPreviousContext = func(err error) error {
		return fmt.Errorf("error setting previous context: %w", err)
	}

	// ErrInvalidSubscriptionID is returned when a subscription ID has an invalid format
	ErrInvalidSubscriptionID = errors.New("invalid subscription ID format")

	// ErrEmptyConfiguration is returned when the configuration is empty or nil
	ErrEmptyConfiguration = errors.New("configuration is empty or nil")
	// ErrInvalidTenantID is returned when a tenant ID has an invalid format
	ErrInvalidTenantID = errors.New("invalid tenant ID format")
	// ErrEmptyTenantName is returned when a tenant name is empty
	ErrEmptyTenantName = errors.New("tenant name cannot be empty")

	// ErrTenantOperation wraps errors that occur during tenant operations
	ErrTenantOperation = func(op string, err error) error {
		return fmt.Errorf("error during tenant operation %s: %w", op, err)
	}

	// ErrTenantNotFound is returned when a tenant is not found
	ErrTenantNotFound = errors.New("tenant not found")
)

Functions

func WrapError

func WrapError(op string, err error) error

WrapError is a helper function that wraps an error with operation context. It takes an operation name and an error, and returns a new error with additional context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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