You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: builder.go
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,8 @@ type Builder struct {
5
5
options []Option
6
6
}
7
7
8
-
// NewBuilder creates a new Builder
8
+
// NewBuilder creates a new Builder.
9
+
// A Builder is useful for creating multiple errors that share a common context, such as a request ID or service name, without repeatedly specifying the same options.
// Empty string ("") is treated as an invalid ID and will not be used for comparison.
29
-
// When ID is set, errors.Is() will compare errors by ID instead of pointer equality.
28
+
// When an ID is set, errors.Is() will compare errors by their ID string instead of by pointer equality. This allows for creating sentinel-like errors that can be matched even if they are wrapped.
29
+
// An empty string ("") is treated as an invalid ID and will not be used for comparison.
// With adds contextual information to an error without modifying the original.
447
-
// If err is goerr.Error, creates a new error preserving existing stacktrace and adds only new values/tags.
448
-
// If err is not goerr.Error, wraps it with new stacktrace and adds values/tags.
446
+
// With adds contextual information to an error without modifying the original. It is useful when you want to enrich an error with more context in a middleware or a higher-level function without altering the original error value.
447
+
//
448
+
// If err is a *goerr.Error, it creates a new *Error that preserves the original stacktrace and adds the new options.
449
+
// If err is a standard error, it wraps the error in a new *goerr.Error with a new stacktrace and adds the options.
0 commit comments