Skip to content
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

Errors go to stdout and don't produce nonzero exit status #148

Open
timdp opened this issue Jan 4, 2023 · 0 comments
Open

Errors go to stdout and don't produce nonzero exit status #148

timdp opened this issue Jan 4, 2023 · 0 comments

Comments

@timdp
Copy link
Contributor

timdp commented Jan 4, 2023

This construct occurs a bunch of times:

if err != nil {
	fmt.Println(err)
	return nil
}

But:

  1. This prints errors to stdout instead of stderr (similar to curl stdout goes to oauth2l stderr #146).
  2. It swallows the error rather than making the program exit with a nonzero status.

Both things make oauth2l unsuitable for use in scripts in particular.

A naive fix would be to replace all these constructs with panic(err.Error()) but it would make more sense to rethrow (well, re-return) errors and add a global error handler that calls os.Exit(code), optionally with a specific code per error type.

I'd be willing to add the panic calls in a PR but I don't think I understand the codebase enough to start a more aggressive refactor.

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

No branches or pull requests

1 participant