Skip to content

Commit 0c87622

Browse files
committed
errors: drop unused StackTrace() function
In PR git-lfs#1466 we introduced our custom "errors" package as a replacement for the "errutil" package used previously to provide various error handling functions and specialized error types. As part of this PR, in commit 8624a87 we defined the StackTrace() function in the new "errors" package, and updated the logPanicToWriter() function in our "commands" package to call it when generating an error log file. We write these log files to the .git/lfs/logs directory whenever a Git LFS command invokes one of our error reporting utility functions such as LoggedError() or Panic(). Later, in commit 377366d of PR git-lfs#2178, we revised the logPanicToWriter() function to use the "%+v" format string specifier when writing an error's details to the log file, and dropped the call to the StackTrace() function of our "errors" package. The StackTrace() call was deemed no longer necessary because we expect all of our errors to be created using our "errors" package's functions, which instantiate error structures defined by the legacy "github.com/pkg/errors" package. This package defines its own Format() methods for its structures so that when the "%+v" format string specifier is used with them, they output both the message and stack trace associated with each error. As a consequence of this change in PR git-lfs#2178, the StackTrace() function in our own custom "errors" package has no remaining callers, so we can remove it now.
1 parent a2b1fef commit 0c87622

File tree

2 files changed

+0
-18
lines changed

2 files changed

+0
-18
lines changed

errors/errors.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,6 @@ func Wrapf(err error, format string, args ...interface{}) error {
8585
return newWrappedError(err, message)
8686
}
8787

88-
func StackTrace(err error) []string {
89-
type stacktrace interface {
90-
StackTrace() errors.StackTrace
91-
}
92-
93-
if err, ok := err.(stacktrace); ok {
94-
frames := err.StackTrace()
95-
lines := make([]string, len(frames))
96-
for i, f := range frames {
97-
lines[i] = fmt.Sprintf("%+v", f)
98-
}
99-
return lines
100-
}
101-
102-
return nil
103-
}
104-
10588
func Join(errs ...error) error {
10689
return goerrors.Join(errs...)
10790
}

errors/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ func IsRetriableLaterError(err error) (time.Time, bool) {
205205

206206
type errorWithCause interface {
207207
Cause() error
208-
StackTrace() errors.StackTrace
209208
error
210209
fmt.Formatter
211210
}

0 commit comments

Comments
 (0)