Skip to content

Commit 2955085

Browse files
authored
Merge pull request #6 from codyoss/master
fixing some linter warning and documentation
2 parents 386e807 + 66e2aaa commit 2955085

File tree

6 files changed

+12
-21
lines changed

6 files changed

+12
-21
lines changed

builder.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ type ErrorBuilder struct {
2020
// NewErrorBuilder creates error builder from an existing error type.
2121
func NewErrorBuilder(t *Type) *ErrorBuilder {
2222
getMode := func() callStackBuildMode {
23-
if t.modifiers.CollectStackTrace() {
24-
return stackTraceCollect
25-
} else {
23+
if !t.modifiers.CollectStackTrace() {
2624
return stackTraceOmit
2725
}
26+
return stackTraceCollect
2827
}
2928

3029
return &ErrorBuilder{
@@ -136,9 +135,8 @@ func (eb *ErrorBuilder) borrowStackTraceFromCause() *stackTrace {
136135
originalStackTrace := eb.extractStackTraceFromCause(eb.cause)
137136
if originalStackTrace != nil {
138137
return originalStackTrace
139-
} else {
140-
return collectStackTrace()
141138
}
139+
return collectStackTrace()
142140
}
143141

144142
func (eb *ErrorBuilder) combineStackTraceWithCause() *stackTrace {

error.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ func (e *Error) Error() string {
173173
func (e *Error) fullMessage() string {
174174
if e.transparent {
175175
return e.messageWithUnderlyingInfo()
176-
} else {
177-
return joinStringsIfNonEmpty(": ", e.errorType.FullName(), e.messageWithUnderlyingInfo())
178176
}
177+
return joinStringsIfNonEmpty(": ", e.errorType.FullName(), e.messageWithUnderlyingInfo())
179178
}
180179

181180
func (e *Error) messageWithUnderlyingInfo() string {

namespace.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,15 @@ func newNamespace(parent *Namespace, name string, traits ...Trait) Namespace {
105105
createName := func() string {
106106
if parent == nil {
107107
return name
108-
} else {
109-
return fmt.Sprintf("%s.%s", parent.FullName(), name)
110108
}
109+
return fmt.Sprintf("%s.%s", parent.FullName(), name)
111110
}
112111

113112
createModifiers := func() modifiers {
114113
if parent == nil {
115114
return noModifiers{}
116-
} else {
117-
return newInheritedModifiers(parent.modifiers)
118115
}
116+
return newInheritedModifiers(parent.modifiers)
119117
}
120118

121119
namespace := Namespace{

switch.go

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

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

66
// CaseNoError is a synthetic trait used in TraitSwitch, signifying an absence of error.

type.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ func newType(namespace Namespace, parent *Type, name string, traits ...Trait) *T
123123
collectModifiers := func() modifiers {
124124
if parent == nil {
125125
return newInheritedModifiers(namespace.modifiers)
126-
} else {
127-
return newInheritedModifiers(parent.modifiers)
128126
}
127+
return newInheritedModifiers(parent.modifiers)
129128
}
130129

131130
collectTraits := func() map[Trait]bool {
@@ -150,9 +149,8 @@ func newType(namespace Namespace, parent *Type, name string, traits ...Trait) *T
150149
createFullName := func() string {
151150
if parent == nil {
152151
return namespace.FullName() + "." + name
153-
} else {
154-
return parent.FullName() + "." + name
155152
}
153+
return parent.FullName() + "." + name
156154
}
157155

158156
t := &Type{

wrap.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@ func DecorateMany(message string, errs ...error) error {
6565
return nil
6666
}
6767

68-
if areAllOfTheSameType(errs...) {
69-
return WrapMany(transparentWrapper, message, errs...)
70-
} else {
68+
if !areAllOfTheSameType(errs...) {
7169
return WrapMany(opaqueWrapper, message, errs...)
7270
}
71+
return WrapMany(transparentWrapper, message, errs...)
7372
}
7473

7574
// WrapMany is a utility to wrap multiple errors.
@@ -110,9 +109,8 @@ func areAllOfTheSameType(errs ...error) bool {
110109

111110
if errorType != nil && errorType != typedError.Type() {
112111
return false
113-
} else {
114-
errorType = typedError.Type()
115112
}
113+
errorType = typedError.Type()
116114
}
117115

118116
return true

0 commit comments

Comments
 (0)