Documentation
¶
Index ¶
- Constants
- func GetStackTrace() string
- func HandleSpanError(ctx context.Context, span trace.Span, log *zap.Logger, msg string, err error, ...)
- func IsSameError(err error, code ErrorCode) bool
- func Raise(code ErrorCode, msg string, errToWrap error) error
- func RaiseToSentry(ctx context.Context, err error)
- func RecoverPanic(msg string) func()
- type AppError
- type ErrorCode
Constants ¶
View Source
const (
SVC string = "HRLD"
)
Variables ¶
This section is empty.
Functions ¶
func HandleSpanError ¶
func IsSameError ¶
IsSameError checks if the error is the same as the given ErrorCode
func RaiseToSentry ¶
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 AsAppError ¶
AsAppError tries to cast the given error to an AppError
func (*AppError) GetErrorCode ¶
func (*AppError) GetMessage ¶
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" )
func ExtractErrorCode ¶
ExtractErrorCode extracts the ErrorCode from an error, if it is an AppError
Click to show internal directories.
Click to hide internal directories.