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

Remove loggedError #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexandrevicenzi
Copy link
Member

Errors are duplicated in the logs because the application exists with log.Fatal and before that the error is logged by loggedError.

Errors are duplicated in the logs because the application exists with
log.Fatal and before that the error is logged by loggedError.

Signed-off-by: Alexandre Vicenzi <[email protected]>
@alexandrevicenzi
Copy link
Member Author

This becomes a bigger problem due to #93 now that all errors are logged to the console and a file.

Copy link
Collaborator

@dcermak dcermak left a comment

Choose a reason for hiding this comment

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

Tbh, I doubt we need the SuseConnectError at all given the changes in #93. There you have effectively removed all usage of the ErrorCode field, so at this point, it's just a fancy wrapper around fmt.Errorf. Do you see any reason why we shouldn't just use fmt.Errorf instead?

@@ -36,10 +40,22 @@ const (
// SuseConnectError is a custom error type allowing us to distinguish between
// different error kinds via the `ErrorCode` field
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// different error kinds via the `ErrorCode` field
// different error kinds via the `Code` field

@alexandrevicenzi
Copy link
Member Author

@dcermak yes, you are right. It seems this is not used anywhere else anymore once #93 is merged.

Removing SuseConnectError should not affect anything, plus it reduces a bit of the code if we use only fmt.Errorf. I can rebase this PR once #93 is merged and replace everything.

Instead of custom errors, we could have log levels and log a bit more, such as Info, Error, and Debug messages to help us in the future once a new bugzilla arises. This is a feature I could see being useful in a future PR.

@@ -33,7 +33,7 @@ func actionWrapper(action func(*cli.Context) error) func(*cli.Context) error {
if err := action(ctx); err != nil {
switch err.(type) {
case *cs.SuseConnectError:
if err.(*cs.SuseConnectError).ErrorCode == cs.GetCredentialsError {
if err.(*cs.SuseConnectError).Code == cs.GetCredentialsError {
Copy link
Member

Choose a reason for hiding this comment

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

If the plan is to use fmt.Errorf you can use errors.Is (or errors.As) if you use %w.

Copy link
Member Author

Choose a reason for hiding this comment

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

This code is going away with #93, this PR needs a rebase once that is merged.

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.

3 participants