Skip to content

Better errors on push#1023

Merged
technoweenie merged 4 commits into
masterfrom
better-errors
Feb 23, 2016
Merged

Better errors on push#1023
technoweenie merged 4 commits into
masterfrom
better-errors

Conversation

@technoweenie

Copy link
Copy Markdown
Contributor

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

$ git push origin master
Trying to push "a.wav" with OID 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7.
Not found in /Users/rick/p/studious-goggles/.git/lfs/objects/87/42.
error: failed to push some refs to 'https://git-server.com/technoweenie/studious-goggles'

Comment thread commands/commands.go
if Debugging || lfs.IsFatalError(err) {
Panic(err, err.Error())
} else {
if inner := lfs.GetInnerError(err); inner != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically err.InnerError() can be another lfs.wrappedError so maybe this should be a loop until that's nil?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 technoweenie merged commit bb68c35 into master Feb 23, 2016
@technoweenie technoweenie deleted the better-errors branch February 23, 2016 17:51
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants