Better errors on push#1023
Merged
Merged
Conversation
| if Debugging || lfs.IsFatalError(err) { | ||
| Panic(err, err.Error()) | ||
| } else { | ||
| if inner := lfs.GetInnerError(err); inner != nil { |
Contributor
There was a problem hiding this comment.
Technically err.InnerError() can be another lfs.wrappedError so maybe this should be a loop until that's nil?
Contributor
Author
There was a problem hiding this comment.
No need because of this. Good call though, I added a test confirming it.
technoweenie
added a commit
that referenced
this pull request
Feb 23, 2016
technoweenie
added a commit
that referenced
this pull request
Feb 23, 2016
This was referenced Feb 23, 2016
technoweenie
added a commit
that referenced
this pull request
Feb 23, 2016
Backport #1023 for v1.1.x: Better errors on push
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 27, 2026
Our "commands" package includes several utility functions which log or output error messages before causing the Git LFS client to exit immediately by calling the Exit() function from the "os" package in the Go standard library. The Exit() function in our "commands" package, which was added in commit 934408e, writes a formatted message to the standard error file descriptor before causing the client to exit with a non-zero status code. The Panic() function also performs these actions, but also expects an additional "error" type parameter, whose message and associated stack trace the function writes to a log file in the ".git/lfs/logs" directory. The initial version of the Panic() function was first added in commit 099c2f1. Both the Exit() and Panic() functions pass a status code of 2 to the Exit() function of the "os" package. In addition to these utility functions, in commit 090944e of PR git-lfs#1023 we added the ExitWithError() function to our "commands" package. This function expects a single "error" type parameter, and then passes this parameter's error message to the Exit() function or passes both the parameter and its message to the Panic() function based on whether the error is considered non-fatal or fatal according to the IsFatalError() function from our "errors" package. However, the implementations of many Git LFS commands simply call the Exit() function from the "os" package directly. In these cases, the commands want to cease operations and halt but do not have an error message they want to output. As well, they often want to return a status code other than 2, which our Exit() and Panic() functions always return. We now replace all these direct calls to the "os" package's Exit() function with calls to a new ExitWithCode() utility function. This new function simply calls the Exit() function from the "os" package and passes the given status code as its parameter. By consistently using our utility functions to call the Exit() function of the "os" package, we minimize the number of changes that will be required in a future PR to guarantee that our commands always perform a common set of cleanup steps before exiting. Note that we also take this opportunity to remove one extra line of whitespace from each of two source files, specifically those for the "git lfs post-checkout" and "git lfs post-commit" commands.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 27, 2026
Our "commands" package includes several utility functions which log or output error messages before causing the Git LFS client to exit immediately by calling the Exit() function from the "os" package in the Go standard library. The Exit() function in our "commands" package, which was added in commit 934408e, writes a formatted message to the standard error file descriptor before causing the client to exit with a non-zero status code. The Panic() function also performs these actions, but also expects an additional "error" type parameter, whose message and associated stack trace the function writes to a log file in the ".git/lfs/logs" directory. The initial version of the Panic() function was first added in commit 099c2f1. Both the Exit() and Panic() functions pass a status code of 2 to the Exit() function of the "os" package. In addition to these utility functions, in commit 090944e of PR git-lfs#1023 we added the ExitWithError() function to our "commands" package. This function expects a single "error" type parameter, and then passes this parameter's error message to the Exit() function or passes both the parameter and its message to the Panic() function based on whether the error is considered non-fatal or fatal according to the IsFatalError() function from our "errors" package. However, the implementations of many Git LFS commands simply call the Exit() function from the "os" package directly. In these cases, the commands want to cease operations and halt but do not have an error message they want to output. As well, they often want to return a status code other than 2, which our Exit() and Panic() functions always return. We now replace all these direct calls to the "os" package's Exit() function with calls to a new ExitWithCode() utility function. This new function simply calls the Exit() function from the "os" package and passes the given status code as its parameter. By consistently using our utility functions to call the Exit() function of the "os" package, we minimize the number of changes that will be required in a future PR to guarantee that our commands always perform a common set of cleanup steps before exiting. Note that we also take this opportunity to remove one extra line of whitespace from each of two source files, specifically those for the "git lfs post-checkout" and "git lfs post-commit" commands.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 27, 2026
Our "commands" package includes several utility functions which log or output error messages before causing the Git LFS client to exit immediately by calling the Exit() function from the "os" package in the Go standard library. The Exit() function in our "commands" package, which was added in commit 934408e, writes a formatted message to the standard error file descriptor before causing the client to exit with a non-zero status code. The Panic() function also performs these actions, but also expects an additional "error" type parameter, whose message and associated stack trace the function writes to a log file in the ".git/lfs/logs" directory. The initial version of the Panic() function was first added in commit 099c2f1. Both the Exit() and Panic() functions pass a status code of 2 to the Exit() function of the "os" package. In addition to these utility functions, in commit 090944e of PR git-lfs#1023 we added the ExitWithError() function to our "commands" package. This function expects a single "error" type parameter, and then passes this parameter's error message to the Exit() function or passes both the parameter and its message to the Panic() function based on whether the error is considered non-fatal or fatal according to the IsFatalError() function from our "errors" package. However, the implementations of many Git LFS commands simply call the Exit() function from the "os" package directly. In these cases, the commands want to cease operations and halt but do not have an error message they want to output. As well, they often want to return a status code other than 2, which our Exit() and Panic() functions always return. We now replace all these direct calls to the "os" package's Exit() function with calls to a new ExitWithCode() utility function. This new function simply calls the Exit() function from the "os" package and passes the given status code as its parameter. By consistently using our utility functions to call the Exit() function of the "os" package, we minimize the number of changes that will be required in a future PR to guarantee that our commands always perform a common set of cleanup steps before exiting. Note that we also take this opportunity to remove one extra line of whitespace from each of two source files, specifically those for the "git lfs post-checkout" and "git lfs post-commit" commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes an issue when pushing or fetching where the "inner error" is dropped, making it difficult to diagnose problems.
This also tweaks an error message from
ensureFile()/cc @rjbell4