Documentation
¶
Index ¶
- Constants
- Variables
- func AddErrType(supply func(id uint32) IErrType) uint32
- func AsSys(code uint32) func(Error)
- func MakeErrCode(typeCode uint32, errCode uint32) uint64
- func PrintCleans(error Error) string
- func PrintDetails(error Error, option *StackPrintOptions) string
- func Throw(err error)
- func ThrowClean(err uint64, msg string)
- func ThrowCleanN(nested Error, err uint64, msg string)
- func ThrowCode(err uint64)
- func ThrowCodeN(nested Error, err uint64)
- func ThrowDetail(err uint64, clean, detail string)
- func ThrowDetailN(nested Error, err uint64, clean, detail string)
- func ThrowErr(err uint64, sys error)
- func ThrowErrN(nested Error, err uint64, sys error)
- func ThrowStringer(err uint64, msg string, meta fmt.Stringer)
- func ThrowStringerN(nested Error, err uint64, msg string, meta fmt.Stringer)
- func Unreachable[T any]() T
- func Unreachable2[T any, U any]() (T, U)
- func Unreachable3[T any, U any, V any]() (T, U, V)
- type Defer
- type DeferT
- type Error
- func ErrByInfo(info ErrorInfo) Error
- func ErrClean(err uint64, msg string) Error
- func ErrCleanN(nested Error, err uint64, msg string) Error
- func ErrCode(err uint64) Error
- func ErrCodeN(nested Error, err uint64) Error
- func ErrDetail(err uint64, clean, detail string) Error
- func ErrDetailN(nested Error, err uint64, clean, detail string) Error
- func ErrErr(err uint64, nested error) Error
- func ErrErrN(nested Error, err uint64, sys error) Error
- func ErrNestByInfo(nested Error, info ErrorInfo) Error
- func ErrStringer(err uint64, msg string, meta fmt.Stringer) Error
- func ErrStringerN(nested Error, err uint64, msg string, meta fmt.Stringer) Error
- type ErrorInfo
- type IErrType
- type Result
- type ResultT
- type StackFrame
- type StackPrintOptions
Constants ¶
const ( // EConfig A configuration error is detected EConfig = 1 // ERequest Request is not able to be served due to procedure prerequisites not satisfied ERequest = 2 // EDenied The requesting party is not granted the access to this resource, or the grant has expired EDenied = 3 // EInternal The request cannot be completed due to an unspecified internal error EInternal = 4 // EStgNone Unable to find given storage record EStgNone = 64 // EStgFull Unable to complete a storage write request due to short of storage quota EStgFull = 65 // EStgQueue Storage data backlog too long EStgQueue = 66 // EStgLost Storage handle lost due to max timeout exceeded during operation EStgLost = 67 // EStgFail Generic storage failure EStgFail = 68 // ENetNone Unable to find give data interface/connection ENetNone = 96 // ENetEarly Data interface/connection not ready ENetEarly = 97 // ENetDown Data interface/connection is down ENetDown = 98 // ENetQueue Data interface/connection backlog too long ENetQueue = 99 // ENetRetry Data request is unable to be completed at the time, retry by user is suggested ENetRetry = 100 // ENetMaxRetry Data request is unable to be completed after max configured automatic retries ENetMaxRetry = 101 // ENetLost Data interface/connection max timeout exceeded ENetLost = 102 // ENetFail Generic data interface/connection failure ENetFail = 103 // EResNone Requested resource not found EResNone = 128 // EResAuth Resource requested authorization not satisfied EResAuth = 129 // EResRetry Resource not available at this time. User retry is suggested EResRetry = 130 // EResGone Resource permanently removed EResGone = 131 // EResFail Resource generic failure EResFail = 132 // ETimeout Action timeout exceeded ETimeout = 512 // ECancel Action cancelled ECancel = 513 // EBacklog Task backlog limit exceeded EBacklog = 514 )
Variables ¶
var ( AsEConfig = AsSys(EConfig) AsERequest = AsSys(ERequest) AsEDenied = AsSys(EDenied) AsEInternal = AsSys(EInternal) AsEStgNone = AsSys(EStgNone) AsEStgFull = AsSys(EStgFull) AsEStgQueue = AsSys(EStgQueue) AsEStgLost = AsSys(EStgLost) AsEStgFail = AsSys(EStgFail) AsENetNone = AsSys(ENetNone) AsENetEarly = AsSys(ENetEarly) AsENetDown = AsSys(ENetDown) AsENetQueue = AsSys(ENetQueue) AsENetRetry = AsSys(ENetRetry) AsENetMaxRetry = AsSys(ENetMaxRetry) AsENetLost = AsSys(ENetLost) AsENetFail = AsSys(ENetFail) AsEResNone = AsSys(EResNone) AsEResAuth = AsSys(EResAuth) AsEResRetry = AsSys(EResRetry) AsEResGone = AsSys(EResGone) AsEResFail = AsSys(EResFail) AsETimeout = AsSys(ETimeout) AsECancel = AsSys(ECancel) AsEBacklog = AsSys(EBacklog) )
var ( FullPrint = &StackPrintOptions{Formatter: _DefaultPrint, TrimStack: false} TrimFullPrint = &StackPrintOptions{Formatter: _DefaultPrint, TrimStack: true} ShortPrint = &StackPrintOptions{Formatter: _DefaultShortPrint, TrimStack: false} TrimShortPrint = &StackPrintOptions{Formatter: _DefaultShortPrint, TrimStack: true} )
Functions ¶
func AddErrType ¶ added in v0.0.2
func MakeErrCode ¶ added in v0.0.2
func PrintCleans ¶ added in v0.0.2
func PrintDetails ¶ added in v0.0.2
func PrintDetails(error Error, option *StackPrintOptions) string
func ThrowClean ¶ added in v0.0.2
ThrowClean Equivalent of Throw(ErrClean(err, msg))
func ThrowCleanN ¶ added in v0.0.2
ThrowCleanN Equivalent of Throw(ErrCleanN(nested, err, msg))
func ThrowCode ¶ added in v0.0.2
func ThrowCode(err uint64)
ThrowCode Equivalent of Throw(ErrCode(err))
func ThrowCodeN ¶ added in v0.0.2
ThrowCodeN Equivalent of Throw(ErrCodeN(nested, err))
func ThrowDetail ¶ added in v0.0.2
ThrowDetail Equivalent of Throw(ErrDetail(err, clean, detail))
func ThrowDetailN ¶ added in v0.0.2
ThrowDetailN Equivalent of Throw(ErrDetailN(nested, err, clean, detail))
func ThrowStringer ¶ added in v0.0.2
ThrowStringer Equivalent of Throw(ErrDetail(err, msg, meta))
func ThrowStringerN ¶ added in v0.0.2
ThrowStringerN Equivalent of Throw(ErrDetailN(nested, err, msg, meta))
func Unreachable ¶
func Unreachable[T any]() T
Unreachable Mark the current return path as unreachable. If an Unreachable is evaluated, an EInternal will be raised
func Unreachable2 ¶ added in v0.0.2
Unreachable2 Mark the current return path as unreachable. If an Unreachable2 is evaluated, an EInternal will be raised
func Unreachable3 ¶ added in v0.0.2
Unreachable3 Mark the current return path as unreachable. If an Unreachable3 is evaluated, an EInternal will be raised
Types ¶
type Defer ¶ added in v0.0.2
type Defer struct {
// contains filtered or unexported fields
}
func UnsafeMakeDefer ¶ added in v0.0.2
func UnsafeMakeDefer() (ret Defer)
func (*Defer) UnsafeApplyDefer ¶ added in v0.0.2
func (c *Defer) UnsafeApplyDefer(exec func())
type DeferT ¶ added in v0.0.2
func UnsafeMakeDeferT ¶ added in v0.0.2
func (*DeferT[T]) UnsafeApplyDefer ¶ added in v0.0.2
func (c *DeferT[T]) UnsafeApplyDefer(exec func() T)
type Error ¶
type Error interface { // TCode : Top error type code TCode() uint32 // ECode : Top error error code ECode() uint32 // Slices : raw []ErrorInfo for all nesting sites Slices() []ErrorInfo // Error : same as detail, for compatibility with golang built-in error handling error }
func ErrByInfo ¶ added in v0.0.2
ErrByInfo Create a new calm.Error with its root slice reference set to info. The corresponding OnErrRoot of the registered calm.IErrType will be called. Stack of the caller will be captured if OnErrRoot reports true. This function should never fail or panic.
func ErrDetailN ¶ added in v0.0.2
ErrDetailN Equivalent of ErrNestByInfo(nested, InfoInfoDetail(err, clean, detail))
func ErrNestByInfo ¶ added in v0.0.2
ErrNestByInfo Return a calm.Error which contains the given nested calm.Error, and with its top level slice set to `info`. If the top-level slice is the exact same as `info` and no stack trace is attached, `nested` is returned. If `info` is returned by calm.InfoCode and the its TCode() and ECode() match the top slice, `nested` is returned. Otherwise, the corresponding OnErrNest of the registered calm.IErrType will be called. Stack of the caller will be captured it `nested` has stack captured or OnErrNest reports true. This function should never fail or panic.
func ErrStringer ¶ added in v0.0.2
ErrStringer Equivalent of ErrByInfo(InfoDetail(err, msg, meta))
type ErrorInfo ¶ added in v0.0.2
type ErrorInfo interface { // TCode : error type code TCode() uint32 // ECode : error error code ECode() uint32 // Detail : message for internal systems, e.g. logging Detail() string // Clean : sanitized short message for passing to the user as error detail Clean() string // Meta : optional metadata object for internal data Meta() any }
func InfoClean ¶ added in v0.0.2
InfoClean construct a ErrorInfo that represents an error code with a sanitized message
func InfoDetail ¶ added in v0.0.2
InfoDetail construct a ErrorInfo that represents an error code with a sanitized message and a full message
type IErrType ¶ added in v0.0.2
type IErrType interface { Type() uint32 // OnErrNest callback on a nested error is created // err: the nested error // return: if stacktrace should be included OnErrNest(err Error) bool // OnErrRoot callback on a new error is created // err: the newly created error // return: if stacktrace should be included OnErrRoot(err Error) bool // ErrName : name tag for a specific error code ErrName(err uint32) string // DefaultMsg get a default clean message for a specific code DefaultMsg(err uint32) string }
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
func ResResultU ¶ added in v0.0.2
type StackFrame ¶ added in v0.0.2
type StackPrintOptions ¶ added in v0.0.2
type StackPrintOptions struct { Formatter func(frame *StackFrame) string TrimStack bool }