errortypes

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package errortypes provides error types and utilities for the projectmemory service.

Index

Constants

This section is empty.

Variables

View Source
var DefaultErrorOutput = errorWriter(2)

DefaultErrorOutput is the default output for error logging

Functions

func IsErrorType

func IsErrorType(err error, errType ErrorType) bool

IsErrorType checks if an error is of a specific type

func LogError

func LogError(err error)

LogError logs an error to stderr, useful for quick error logging without a logger

Types

type ErrorType

type ErrorType string

ErrorType represents the category of an error

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

Error type constants

type TypedError

type TypedError struct {
	// contains filtered or unexported fields
}

TypedError is an error with an associated error type

func APIError

func APIError(err error, message string) *TypedError

APIError creates an API error

func ConfigError

func ConfigError(err error, message string) *TypedError

ConfigError creates a configuration error

func DatabaseError

func DatabaseError(err error, message string) *TypedError

DatabaseError creates a database error

func ExternalError

func ExternalError(err error, message string) *TypedError

ExternalError creates an external service error

func InternalError

func InternalError(err error, message string) *TypedError

InternalError creates an internal error

func NetworkError

func NetworkError(err error, message string) *TypedError

NetworkError creates a network error

func PermissionError

func PermissionError(err error, message string) *TypedError

PermissionError creates a permission error

func ValidationError

func ValidationError(err error, message string) *TypedError

ValidationError creates a validation error

func (*TypedError) Error

func (e *TypedError) Error() string

Error returns the error message

func (*TypedError) GetField

func (e *TypedError) GetField(key string) (interface{}, bool)

GetField retrieves metadata from the error

func (*TypedError) Type

func (e *TypedError) Type() ErrorType

Type returns the error type

func (*TypedError) Unwrap

func (e *TypedError) Unwrap() error

Unwrap returns the underlying error

func (*TypedError) WithField

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

WithField adds metadata to the error

Jump to

Keyboard shortcuts

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