porter
porter copied to clipboard
Print error stack traces in debug mode
When porter is run in debug mode, with the --debug flag or config setting, then when our main program exits with an error, we shouldn't rely on the default cobra error handling. We should print the error with the included stack trace provided by the github.com/pkg/errors package.
That way we can more quickly drill down to where the error happened without doing greps on the error message.
It's not immediately clear to me how to provide our own error printing with cobra. But if we make this change on the v1 branch, we can check if p.Debug is set and print it before exiting.
https://github.com/getporter/porter/blob/9f88c6f8bc7066da70b67819013fcfbb4e12a9a9/cmd/porter/main.go#L18-L26
This change should be made against the release/v1 branch.
See our Contributing Tutorial and New Contributor Guide for help getting started contributing to Porter.
We should print the error with the included stack trace provided by the github.com/pkg/errors package.
Given #2009 do we want to work towards removing the dependency on github.com/pkg/errors entirely and use something else here? Should runtime/debug be used in its place to implement this?
@kevinbarbour Yes, thanks for picking up on the out-of-date implementation recommendation. runtime/debug is what we'd want to use