Documentation
¶
Overview ¶
Package errortypes provides error types and utilities for the projectmemory service.
Index ¶
- Variables
- func IsErrorType(err error, errType ErrorType) bool
- func LogError(err error)
- type ErrorType
- type TypedError
- func APIError(err error, message string) *TypedError
- func ConfigError(err error, message string) *TypedError
- func DatabaseError(err error, message string) *TypedError
- func ExternalError(err error, message string) *TypedError
- func InternalError(err error, message string) *TypedError
- func NetworkError(err error, message string) *TypedError
- func PermissionError(err error, message string) *TypedError
- func ValidationError(err error, message string) *TypedError
Constants ¶
This section is empty.
Variables ¶
var DefaultErrorOutput = errorWriter(2)
DefaultErrorOutput is the default output for error logging
Functions ¶
func IsErrorType ¶
IsErrorType checks if an error is of a specific type
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 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) GetField ¶
func (e *TypedError) GetField(key string) (interface{}, bool)
GetField retrieves metadata from the error
func (*TypedError) WithField ¶
func (e *TypedError) WithField(key string, value interface{}) *TypedError
WithField adds metadata to the error