Skip to content

Commit 090d063

Browse files
committed
godoc
1 parent f8c7ffe commit 090d063

File tree

7 files changed

+17
-13
lines changed

7 files changed

+17
-13
lines changed

common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package errorx
22

33
var (
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")

modifier.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package 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.
77
type TypeModifier int
88

99
const (
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

namespace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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.
2121
type NamespaceKey struct {
2222
id int64
2323
name string

property.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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.
2222
func 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.
2727
func PropertyPayload() Property {
2828
return propertyPayload
2929
}

stacktrace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
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.
1313
type StackTraceFilePathTransformer func(string) string
1414

1515
// InitializeStackTraceTransformer provides a transformer to be used in formatting of all the errors.

switch.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package errorx
22

3+
// CaseNoTrait is a synthetic type used in TypeSwitch, signifying a presence of non-nil error of some other type.
34
func NotRecognisedType() *Type { return notRecognisedType }
45

6+
// CaseNoError is a synthetic trait used in TraitSwitch, signifying an absence of error.
57
func 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.
610
func CaseNoTrait() Trait { return caseNoTrait }
711

812
var (
@@ -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.
4852
func TraitSwitch(err error, traits ...Trait) Trait {
4953
typed := Cast(err)

trait.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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.
3030
func 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.
3333
func 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.
3636
func 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.
3939
func Duplicate() Trait { return traitDuplicate }
4040

4141
// IsTemporary checks for Temporary trait.

0 commit comments

Comments
 (0)