12345678910111213141516171819202122232425262728293031323334353637 |
- package errors
- import (
- stderrors "errors"
- "fmt"
- )
- // Standard errors that can be used across packages
- var (
- ErrNotFound = stderrors.New("resource not found")
- ErrInvalidInput = stderrors.New("invalid input")
- ErrUnauthorized = stderrors.New("unauthorized")
- ErrInternalServer = stderrors.New("internal server error")
- ErrDatabaseOperation = stderrors.New("database operation failed")
- )
- // ConfigError represents a configuration-related error
- type ConfigError struct {
- Section string
- Err error
- }
- func (e *ConfigError) Error() string {
- return fmt.Sprintf("configuration error in %s: %v", e.Section, e.Err)
- }
- func (e *ConfigError) Unwrap() error {
- return e.Err
- }
- // NewConfigError creates a new ConfigError
- func NewConfigError(section string, err error) *ConfigError {
- return &ConfigError{
- Section: section,
- Err: err,
- }
- }
|