errors

package
v0.0.0-...-ce673dc Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PgDuplicateObjectCode = "42710"
)
View Source
const (
	SVC string = "HRLD"
)

Variables

This section is empty.

Functions

func GetStackTrace

func GetStackTrace() string

GetStackTrace returns a human-readable stack trace

func HandleSpanError

func HandleSpanError(ctx context.Context, span trace.Span, log *zap.Logger, msg string, err error, extraFields ...zap.Field)

func Raise

func Raise(code ErrorCode, msg string, errToWrap error) error

Raise is a general util to construct domain errors

func RaiseToSentry

func RaiseToSentry(ctx context.Context, err error)

RaiseToSentry raises the error to Sentry

func RecoverPanic

func RecoverPanic(msg string) func()

RecoverPanic can be deferred to capture and log a panic

Types

type AppError

type AppError struct {
	ErrorCode ErrorCode // unique error code
	Message   string    // optional human-readable message
	Cause     error     // wrapped error
}

AppError represents an application error with a code, message, cause, and extra data

func (*AppError) Error

func (ae *AppError) Error() string

func (*AppError) GetCode

func (ae *AppError) GetCode() string

func (*AppError) GetErrorCode

func (ae *AppError) GetErrorCode() ErrorCode

func (*AppError) GetMessage

func (ae *AppError) GetMessage() string

func (*AppError) Unwrap

func (ae *AppError) Unwrap() error

type ErrorCode

type ErrorCode string

ErrorCode type

const (
	// System errors
	ErrInternalError ErrorCode = "SYS-00"

	// Fact errors
	ErrFactInvalidKey       ErrorCode = "FACT-01"
	ErrFactInvalidType      ErrorCode = "FACT-02"
	ErrFactInvalidOccuredAt ErrorCode = "FACT-03"
	ErrFactInvalidField     ErrorCode = "FACT-04"
	ErrFactMarshalFailed    ErrorCode = "FACT-05"

	// Cache errors
	ErrCacheCallFailed ErrorCode = "CACHE-01"

	// Kafka errors
	ErrKafkaProducerCreationFailed ErrorCode = "KAFKA-01"
	ErrKafkaProduceFailed          ErrorCode = "KAFKA-02"

	// K8s errors
	ErrK8sInformerCreationFailed ErrorCode = "K8S-01"
	ErrK8sCacheFailed            ErrorCode = "K8S-02"

	// Postgres errors
	ErrPostgresConnectionFailed  ErrorCode = "PG-01"
	ErrPostgresPublicationFailed ErrorCode = "PG-02"
	ErrPostgresReplicationFailed ErrorCode = "PG-03"
	ErrPostgresStandbyFailed     ErrorCode = "PG-04"
	ErrPostgresRelationMissing   ErrorCode = "PG-05"
	ErrPostgresHandlerMissing    ErrorCode = "PG-06"
	ErrPostgresInvalidValue      ErrorCode = "PG-07"
)

Jump to

Keyboard shortcuts

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