errortypes

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package errortypes provides error types and handling for ProjectMemory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDatabaseError added in v0.1.4

func IsDatabaseError(err error) bool

IsDatabaseError checks if an error is a database error

func IsNetworkError added in v0.1.4

func IsNetworkError(err error) bool

IsNetworkError checks if an error is a network error

func IsPermissionError added in v0.1.4

func IsPermissionError(err error) bool

IsPermissionError checks if an error is a permission error

func IsValidationError added in v0.1.4

func IsValidationError(err error) bool

IsValidationError checks if an error is a validation error

func LogError

func LogError(logger *slog.Logger, err error)

LogError logs an AppError using the provided slog.Logger or the default slog logger. It logs the error message, type, stack trace, and any associated fields.

Types

type AppError added in v0.1.4

type AppError struct {
	Err       error
	Type      ErrorType
	Message   string
	StackInfo string
	Fields    map[string]interface{}
}

AppError represents an application error with context

func APIError

func APIError(err error, message string) *AppError

APIError creates a new API error

func ConfigError

func ConfigError(err error, message string) *AppError

ConfigError creates a new configuration error

func DatabaseError

func DatabaseError(err error, message string) *AppError

DatabaseError creates a new database error

func ExternalError

func ExternalError(err error, message string) *AppError

ExternalError creates a new external error

func InternalError

func InternalError(err error, message string) *AppError

InternalError creates a new internal error

func NetworkError

func NetworkError(err error, message string) *AppError

NetworkError creates a new network error

func PermissionError

func PermissionError(err error, message string) *AppError

PermissionError creates a new permission error

func ValidationError

func ValidationError(err error, message string) *AppError

ValidationError creates a new validation error

func (*AppError) Error added in v0.1.4

func (e *AppError) Error() string

Error implements the error interface

func (*AppError) Unwrap added in v0.1.4

func (e *AppError) Unwrap() error

Unwrap unwraps the error to support errors.Is and errors.As

func (*AppError) WithField added in v0.1.4

func (e *AppError) WithField(key string, value interface{}) *AppError

WithField adds a field to the error for additional context

func (*AppError) WithFields added in v0.1.4

func (e *AppError) WithFields(fields map[string]interface{}) *AppError

WithFields adds multiple fields to the error for additional context

type ErrorType

type ErrorType string

ErrorType represents the type of error that occurred

const (
	ErrorTypeValidation ErrorType = "validation"
	ErrorTypePermission ErrorType = "permission"
	ErrorTypeDatabase   ErrorType = "database"
	ErrorTypeNetwork    ErrorType = "network"
	ErrorTypeAPI        ErrorType = "api"
	ErrorTypeConfig     ErrorType = "config"
	ErrorTypeInternal   ErrorType = "internal"
	ErrorTypeExternal   ErrorType = "external"
)

Error types

Jump to

Keyboard shortcuts

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