Skip to content

Commit e93a7a4

Browse files
committed
fix dogoc comments
1 parent b73328a commit e93a7a4

3 files changed

Lines changed: 22 additions & 28 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ And, finally, handled by printing it to the log file:
2828
log.Errorf("Error: %s", err)
2929
```
3030

31-
It doesn't take long to find out that this is not often enough. There's little fun in solving the issue when everything a developer is able to observe is a line in the log that looks like on of those:
31+
It doesn't take long to find out that quite often this is not enough. There's little fun in solving the issue when everything a developer is able to observe is a line in the log that looks like on of those:
3232
> Error: EOF
3333
3434
> Error: unexpected '>' at the beginning of value

builder.go

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"strconv"
66
)
77

8-
// Utility to compose an error from type
9-
// Typically, a direct usage is not required: either Type methods of helpers like Decorate is sufficient
10-
// Only use builder if no neater alternative is available
8+
// ErrorBuilder is a utility to compose an error from type.
9+
// Typically, a direct usage is not required: either Type methods of helpers like Decorate is sufficient.
10+
// Only use builder if no neater alternative is available.
1111
type ErrorBuilder struct {
1212
errorType *Type
1313
message string
@@ -17,7 +17,7 @@ type ErrorBuilder struct {
1717
isTransparent bool
1818
}
1919

20-
// Created error builder from an existing error type
20+
// NewErrorBuilder created error builder from an existing error type
2121
func NewErrorBuilder(t *Type) *ErrorBuilder {
2222
getMode := func() callStackBuildMode {
2323
if t.modifiers.CollectStackTrace() {
@@ -34,10 +34,10 @@ func NewErrorBuilder(t *Type) *ErrorBuilder {
3434
}
3535
}
3636

37-
// Provide an original cause for error
38-
// For non-errorx errors, a stack trace is collected
39-
// Otherwise, it is inherited by default, as error wrapping is typically performed 'en passe'
40-
// Note that even if an original error explicitly omitted the stack trace, it could be added on wrap
37+
// WithCause provides an original cause for error.
38+
// For non-errorx errors, a stack trace is collected.
39+
// Otherwise, it is inherited by default, as error wrapping is typically performed 'en passe'.
40+
// Note that even if an original error explicitly omitted the stack trace, it could be added on wrap.
4141
func (eb *ErrorBuilder) WithCause(err error) *ErrorBuilder {
4242
eb.cause = err
4343
if Cast(err) != nil {
@@ -47,9 +47,10 @@ func (eb *ErrorBuilder) WithCause(err error) *ErrorBuilder {
4747
return eb
4848
}
4949

50-
// Transparent wrap hides the current error type from the type checks and exposes the error type of the cause instead
51-
// The same holds true for traits, and the dynamic properties are visible from both cause and transparent wrapper
52-
// Note that if the cause error is non-errorx, transparency will still hold, type check against wrapper will still fail
50+
// Transparent makes a wrap transparent rather than opaque (default).
51+
// Transparent wrap hides the current error type from the type checks and exposes the error type of the cause instead.
52+
// The same holds true for traits, and the dynamic properties are visible from both cause and transparent wrapper.
53+
// Note that if the cause error is non-errorx, transparency will still hold, type check against wrapper will still fail.
5354
func (eb *ErrorBuilder) Transparent() *ErrorBuilder {
5455
if eb.cause == nil {
5556
panic("wrong builder usage: wrap modifier without non-nil cause")
@@ -59,11 +60,11 @@ func (eb *ErrorBuilder) Transparent() *ErrorBuilder {
5960
return eb
6061
}
6162

62-
// Collect the current stack trace along with the original one, and use both in formatting
63-
// If the original error does not hold a stack trace for whatever reason, it will be collected it this point
64-
// This is typically a way to handle an error received from another goroutine - say, a worker pool
63+
// EnhanceStackTrace is a signal to collect the current stack trace along with the original one, and use both in formatting.
64+
// If the original error does not hold a stack trace for whatever reason, it will be collected it this point.
65+
// This is typically a way to handle an error received from another goroutine - say, a worker pool.
6566
// When stack traces overlap, formatting makes a conservative attempt not to repeat itself,
66-
// preserving the *original* stack trace in its entirety
67+
// preserving the *original* stack trace in its entirety.
6768
func (eb *ErrorBuilder) EnhanceStackTrace() *ErrorBuilder {
6869
if eb.cause == nil {
6970
panic("wrong builder usage: wrap modifier without non-nil cause")
@@ -78,16 +79,9 @@ func (eb *ErrorBuilder) EnhanceStackTrace() *ErrorBuilder {
7879
return eb
7980
}
8081

81-
// Adds multiple additional (hidden, suppressed) related errors to be used exclusively in error output
82-
// Note that these errors make no other effect whatsoever: their traits, types, properties etc. are lost
83-
func (eb *ErrorBuilder) withUnderlyingErrors(errs ...error) *ErrorBuilder {
84-
eb.underlying = append(eb.underlying, errs...)
85-
return eb
86-
}
87-
88-
// Provides a message for an error in flexible format, to simplify its usages
89-
// Without args, leaves the original message intact, so a message may be generated or provided externally
90-
// With args, a formatting is performed, and it is therefore expected a format string to be constant
82+
// WithConditionallyFormattedMessage provides a message for an error in flexible format, to simplify its usages.
83+
// Without args, leaves the original message intact, so a message may be generated or provided externally.
84+
// With args, a formatting is performed, and it is therefore expected a format string to be constant.
9185
func (eb *ErrorBuilder) WithConditionallyFormattedMessage(message string, args ...interface{}) *ErrorBuilder {
9286
if len(args) == 0 {
9387
eb.message = message
@@ -98,7 +92,7 @@ func (eb *ErrorBuilder) WithConditionallyFormattedMessage(message string, args .
9892
return eb
9993
}
10094

101-
// Returns an error with specified params
95+
// Create returns an error with specified params
10296
func (eb *ErrorBuilder) Create() *Error {
10397
return &Error{
10498
errorType: eb.errorType,

readme.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//
1616
// log.Errorf("Error: %s", err)
1717
//
18-
// This approach is simple, but it is often not enough.
18+
// This approach is simple, but quite often it is not enough.
1919
// There is a need to add context information to error, to check or hide its properties.
2020
// If all else fails, it pays to have a stack trace printed along with error text.
2121
//

0 commit comments

Comments
 (0)