Versions in this module Expand all Collapse all v0 v0.3.1 Mar 14, 2024 Changes in this version + func IsValidation(err error) bool + func JSONResponse(w http.ResponseWriter, err error, options ...JSONResponseOption) error + func TraceID(id string, t error) error + type Base struct + Msg string + Status int + Timestamp time.Time + TraceID string + func NewBase(status int, format string, args ...any) Base + func (b *Base) GetBase() *Base + func (b *Base) SetTraceID(id string) + type ConflictError struct + Errors MarshalableErrors + Item any + func AsConflict(err error) (cerr *ConflictError, b bool) + func (e *ConflictError) AddError(err error) *ConflictError + func (e *ConflictError) Error() string + func (e *ConflictError) HttpStatus() int + func (e *ConflictError) Is(t error) bool + type InternalError struct + Err error + Stacktrace json.RawMessage + func AsInternal(err error) (ierr *InternalError, b bool) + func (e *InternalError) Error() string + func (e *InternalError) HttpStatus() int + type JSONResponseFunc func(*Base) + func ProcessStatus(fn func(status int) error) JSONResponseFunc + func WithTraceID(traceID string) JSONResponseFunc + func (f JSONResponseFunc) Apply(b *Base) + type JSONResponseOption interface + Apply func(*Base) + type MarshalableErrors []error + func (me MarshalableErrors) MarshalJSON() ([]byte, error) + type NotFoundError struct + Item any + func AsNotFound(err error) (nerr *NotFoundError, b bool) + func (e *NotFoundError) Error() string + func (e *NotFoundError) HttpStatus() int + func (e *NotFoundError) Is(err error) bool + type NotImplementedError struct + func (e *NotImplementedError) Error() string + func (e *NotImplementedError) HttpStatus() int + type PreconditionFailedError struct + Err error + func (e *PreconditionFailedError) Error() string + func (e *PreconditionFailedError) HttpStatus() int + func (e *PreconditionFailedError) SetErr(err error) *PreconditionFailedError + type UnauthenticatedError struct + func (e *UnauthenticatedError) Error() string + func (e *UnauthenticatedError) HttpStatus() int + type UnauthorizedError struct + func (e *UnauthorizedError) Error() string + func (e *UnauthorizedError) HttpStatus() int + type ValidationError struct + Errors MarshalableErrors + func AsValidation(err error) (verr *ValidationError, b bool) + func Validation(format string, args ...any) *ValidationError + func (e *ValidationError) AddError(err error) *ValidationError + func (e *ValidationError) Error() string + func (e *ValidationError) HttpStatus() int + func (e *ValidationError) Is(err error) bool v0.3.0 Nov 21, 2023 Changes in this version + type Code string + const CodeAborted + const CodeConflict + const CodeInternal + const CodeInvalidArgument + const CodeNotFound + const CodeNotImplemented + const CodePreconditionFailed + const CodeUnauthenticated + const CodeUnauthorized + func AsCode(err error) Code type Status + Code Code + Err error + Message string + Payload any + func (e *Status) Detail(arg any) *Status + func (e *Status) Error() string + func (e *Status) Http() int + func (e *Status) Source(err error) *Status + func (e *Status) Unwrap() error v0.2.0 Nov 20, 2023 Changes in this version + var HttpMap = map[Status]int + func As(err error, target any) bool + func Detail[T any](err error) (detail *T) + func HttpStatus(err error) int + func Is(err error, target error) bool + func IsAborted(err error) bool + func IsConflict(err error) bool + func IsInternal(err error) bool + func IsInvalidArgument(err error) bool + func IsNotFound(err error) bool + func IsNotImplemented(err error) bool + func IsPreconditionFailed(err error) bool + func IsStatus(err error) bool + func IsUnauthenticated(err error) bool + func IsUnauthorized(err error) bool + func Join(errs ...error) error + func Message(err error) string + func New(text string) error + func Source(err error) error + func Unwrap(err error) error + type Error struct + Err error + Message string + Status Status + func Aborted(format string, args ...interface{}) *Error + func AsError(err error) (e *Error) + func Conflict(format string, args ...interface{}) *Error + func Format(code Status, format string, args ...interface{}) *Error + func Internal(format string, args ...interface{}) *Error + func InvalidArgument(format string, args ...interface{}) *Error + func NotFound(format string, args ...interface{}) *Error + func NotImplemented(format string, args ...interface{}) *Error + func PreconditionFailed(format string, args ...interface{}) *Error + func Unauthenticated(format string, args ...interface{}) *Error + func Unauthorized(format string, args ...interface{}) *Error + func (e *Error) Detail(arg any) *Error + func (e *Error) Error() string + func (e *Error) Http() int + func (e *Error) Source(err error) *Error + func (e *Error) Unwrap() error + type Status string + const StatusAborted + const StatusConflict + const StatusInternal + const StatusInvalidArgument + const StatusNotFound + const StatusNotImplemented + const StatusPreconditionFailed + const StatusUnauthenticated + const StatusUnauthorized + func AsStatus(err error) Status