Conversation
errors/context.go
Outdated
| @@ -0,0 +1,42 @@ | |||
| package errors | |||
|
|
|||
| type errorWithContext interface { | |||
There was a problem hiding this comment.
This name is slightly misleading, since errorWithContext isn't actually an error.
There was a problem hiding this comment.
Also, the prefix is redundant. I think we should go with withContext, and methods like SetContext() instead of ErrorSetContext().
|
Aside from my one comment, 👍 . |
|
Using pkg/errors really reduces the stack trace: current masterthis pr |
|
You can replicate this with: $ git lfs install --skip-smudge
$ git clone https://github.com/small/repo/with/lfs/objects
$ cd working-dir
$ git lfs checkoutThis raises the same error because the |
|
Fixed the problem. Turns out we're on an old version of the pkg/errors package, so I was looking at the wrong code. 8624a87 changes the formatting for the error from My change adds an I now have a full stacktrace: |
|
Awesome find, glad that wasn't as involved as I was thinking it would be 😅 |
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.
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.
This renames the
github/git-lfs/errutilpackage togithub/git-lfs/errors, and encourages its use in the rest of the codebase instead oferrorsorgithub.com/pkg/errors.This is still (mostly) API compatible with both, and means we don't have to import multiple error packages in Git LFS itself.