-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new(error.go): catch exec.ExitError and return error #68
Conversation
Alternatively, I suggest removing what my commit adds and instead catching it further up: if err := npmPackageLockOnly.Run(); err != nil {
if e, ok := err.(*exec.ExitError); !ok {
fmt.Printf("npm subprocess terminated with status code %s\n", e.ProcessState)
}
return []byte{}, pkgcontext.OutputErrorf(ctx, err, "couldn't generate the package-lock.json file")
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
But left a comment :)
@@ -29,6 +30,9 @@ func Error(ctx context.Context, input error) error { | |||
if e, ok := input.(net.Error); ok && e.Timeout() { | |||
return context.DeadlineExceeded | |||
} | |||
if e, ok := input.(*exec.ExitError); ok { | |||
return fmt.Errorf("subprocess terminated with status code %s", e.ProcessState) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The e
instance contains also the Stderr
byte slice.
We could think of appending it to this error string.
Can you send a screenshot of what the Stderr
byte slice contains so we can decide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to:
- check if
len(e.Stderr) > 0
- if so, append it to the error with
string(e.Stderr)
Signed-off-by: Francesco Di Donato <didonato.fr@gmail.com>
Signed-off-by: Francesco Di Donato <didonato.fr@gmail.com>
cb33a6c
to
030d4dd
Compare
If the input to the
in
(package.json) command is invalid, there is little that can be done. It can happen, however, that it is valid but makes (incorrectly in my opinion) assumptions about the presence of certain executables on the host. This is the case ofnode-sdk
, as seen in #62.After internal analysis with @leodido, I propose a simple casting of the error in order to give more information about why the failure occurred.
Fixes #67
Signed-off-by: Francesco Di Donato didonato.fr@gmail.com