File tree Expand file tree Collapse file tree 7 files changed +17
-13
lines changed Expand file tree Collapse file tree 7 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 11package errorx
22
33var (
4- // General purpose errors to be used universally .
4+ // CommonErrors is a namespace for general purpose errors designed for universal use .
55 // These errors should typically be used in opaque manner, implying no handing in user code.
66 // When handling is required, it is best to use custom error types with both standard and custom traits.
77 CommonErrors = NewNamespace ("common" )
Original file line number Diff line number Diff line change 11package errorx
22
3- // Modifier is a way to change a default behaviour for an error type, directly or via type hierarchy.
3+ // TypeModifier is a way to change a default behaviour for an error type, directly or via type hierarchy.
44// Modification is intentionally one-way, as it provides much more clarity.
55// If there is a modifier on a type or a namespace, all its descendants definitely have the same default behaviour.
66// If some of a subtypes must lack a specific modifier, then the modifier must be removed from the common ancestor.
77type TypeModifier int
88
99const (
10- // An error type with such modifier creates transparent wrappers by default
10+ // TypeModifierTransparent is a type modifier; an error type with such modifier creates transparent wrappers by default
1111 TypeModifierTransparent TypeModifier = 1
12- // An error type with such modifier omits the stack trace collection upon creation of an error instance
12+ // TypeModifierOmitStackTrace is a type modifier; an error type with such modifier omits the stack trace collection upon creation of an error instance
1313 TypeModifierOmitStackTrace TypeModifier = 2
1414)
1515
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ type Namespace struct {
1717 modifiers modifiers
1818}
1919
20- // Namespace itself is not comparable, so a key be used instead .
20+ // NamespaceKey is a comparable descriptor of a Namespace .
2121type NamespaceKey struct {
2222 id int64
2323 name string
Original file line number Diff line number Diff line change @@ -18,12 +18,12 @@ func RegisterProperty(label string) Property {
1818 return newProperty (label )
1919}
2020
21- // Context property, value is expected to be of context.Context type.
21+ // PropertyContext is a context property, value is expected to be of context.Context type.
2222func PropertyContext () Property {
2323 return propertyContext
2424}
2525
26- // Payload property, value may contain user defined structure with arbitrary data passed along with an error.
26+ // PropertyPayload is a payload property, value may contain user defined structure with arbitrary data passed along with an error.
2727func PropertyPayload () Property {
2828 return propertyPayload
2929}
Original file line number Diff line number Diff line change 99 "sync/atomic"
1010)
1111
12- // A used defined transformer for file path in stack trace output
12+ // StackTraceFilePathTransformer is a used defined transformer for file path in stack trace output.
1313type StackTraceFilePathTransformer func (string ) string
1414
1515// InitializeStackTraceTransformer provides a transformer to be used in formatting of all the errors.
Original file line number Diff line number Diff line change 11package errorx
22
3+ // CaseNoTrait is a synthetic type used in TypeSwitch, signifying a presence of non-nil error of some other type.
34func NotRecognisedType () * Type { return notRecognisedType }
45
6+ // CaseNoError is a synthetic trait used in TraitSwitch, signifying an absence of error.
57func CaseNoError () Trait { return caseNoError }
8+
9+ // CaseNoTrait is a synthetic trait used in TraitSwitch, signifying a presence of non-nil error that lacks specified traits.
610func CaseNoTrait () Trait { return caseNoTrait }
711
812var (
@@ -43,7 +47,7 @@ func TypeSwitch(err error, types ...*Type) *Type {
4347// For error types that lack any of the provided traits, including non-errorx errors, CaseNoTrait() is returned.
4448// It is safe to treat CaseNoTrait() as 'any other kind of not-nil error' case.
4549// The effect is equivalent to a series of HasTrait() checks.
46-
50+ //
4751// NB: if more than one provided types matches the error, the first match in the providers list is recognised.
4852func TraitSwitch (err error , traits ... Trait ) Trait {
4953 typed := Cast (err )
Original file line number Diff line number Diff line change @@ -26,16 +26,16 @@ func HasTrait(err error, key Trait) bool {
2626 return typedErr .HasTrait (key )
2727}
2828
29- // A trait that signifies that an error is temporary in nature.
29+ // Temporary is a trait that signifies that an error is temporary in nature.
3030func Temporary () Trait { return traitTemporary }
3131
32- // A trait that signifies that an error is some sort iof timeout.
32+ // Timeout is a trait that signifies that an error is some sort iof timeout.
3333func Timeout () Trait { return traitTimeout }
3434
35- // A trait that marks such an error where the requested object is not found.
35+ // NotFound is a trait that marks such an error where the requested object is not found.
3636func NotFound () Trait { return traitNotFound }
3737
38- // A trait that marks such an error where an update is failed as a duplicate.
38+ // Duplicate is a trait that marks such an error where an update is failed as a duplicate.
3939func Duplicate () Trait { return traitDuplicate }
4040
4141// IsTemporary checks for Temporary trait.
You can’t perform that action at this time.
0 commit comments