Skip to content

[errors] Show better errors when user script errors out and fix poetry plugin #1511

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

Merged
merged 2 commits into from
Sep 29, 2023

Conversation

mikeland73
Copy link
Contributor

@mikeland73 mikeland73 commented Sep 28, 2023

  • When a user script errors out, show the error code (e.g. Error: exit status 1) This helps in cases when stderr is empty (which the previous --quiet was causing)
  • Improve poetry plugin by removing --quiet flag and adding more required into in readme.

Possible future improements:

  • Better error when python is not installed
  • Better error when pyproject is missing
  • Allow custom pyproject locations

Summary

How was it tested?

image

New implementation

image

@mikeland73 mikeland73 requested review from savil and Lagoja September 28, 2023 20:36
@savil
Copy link
Collaborator

savil commented Sep 29, 2023

I don't understand the Test Plan. Why is devbox run echo 5 complaining about python?

@@ -81,6 +81,7 @@ func (ex *midcobraExecutable) Execute(ctx context.Context, args []string) int {
var exitErr *exec.ExitError
var userExecErr *usererr.ExitError
if errors.As(err, &userExecErr) {
ux.Ferror(ex.cmd.ErrOrStderr(), userExecErr.Error()+"\n")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion. Also print the Stderr since it may have other info.

We do similar in midcobra/debug.go: https://github.com/jetpack-io/devbox/blob/42d2f713fde840558faeb9d404b8f5e9e2f697dd/internal/boxcli/midcobra/debug.go#L67

@mikeland73
Copy link
Contributor Author

I don't understand the Test Plan. Why is devbox run echo 5 complaining about python?

Sorry, I should have been more specific. I added poetry and then ran the echo line. The error you see is poetry complaining python is not installed. The error is not visible because --quiet was removed. The next line (Error exit status 1) is now visible due to the new code that prints the ExitError

@mikeland73
Copy link
Contributor Author

@savil I changed the implementation a bit. Instead of printing error in midcobra which is wrong, we print it in the debug middleware.

I added code to ensure telemetry does not log user errors.

Copy link
Collaborator

@savil savil left a comment

Choose a reason for hiding this comment

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

coolio

@mikeland73 mikeland73 merged commit 56dcac5 into main Sep 29, 2023
@mikeland73 mikeland73 deleted the landau/better-errors branch September 29, 2023 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants