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

TestRootWrapping #23

Closed
wants to merge 4 commits into from
Closed

TestRootWrapping #23

wants to merge 4 commits into from

Conversation

CAJan93
Copy link
Collaborator

@CAJan93 CAJan93 commented Feb 5, 2024

What's changed and what's your intention?

eris.Wrapf(err, "failed to get user by email %s", email)
results in below, but the SQLSTATE 42703 should be root

{
    "external": "ERROR: column \"password\" does not exist (SQLSTATE 42703)",
    "root": {
        "code": "internal",
        "message": "failed to get user by email [email protected]"
    }
}

Checklist

  • I have written the necessary docs and comments
  • I have added necessary unit tests and integration tests

Refer to a related PR or issue link (optional)

@CAJan93
Copy link
Collaborator Author

CAJan93 commented Feb 5, 2024

@Gogomoe @Nebulazhang I think this is because we are creating regular errors instead of eris.Errorf. Do you think it makes sense to replace all the root errors with eris.statusError using eris.Errorf?

@Gogomoe
Copy link
Collaborator

Gogomoe commented Feb 8, 2024

Do you think it makes sense to replace all the root errors with eris.statusError using eris.Errorf?

We are able to create statusError by eris.Errorf(message).WithCode(eris.CodeNotFound)

@Gogomoe
Copy link
Collaborator

Gogomoe commented Feb 8, 2024

eris.Wrapf(err, "failed to get user by email %s", email)
results in below, but the SQLSTATE 42703 should be root

The message looks good to me. If an error is produced by external library and we warp it by eris.Wrap, we should focus on the external field.
If the error is entirely produced in our codes eris.New or eris.Errorf, then we should focus on the root

@CAJan93
Copy link
Collaborator Author

CAJan93 commented Feb 8, 2024

Fair enough @Gogomoe. I was just confused because the order in which the error are logged is not the one in which they are thrown.

@CAJan93 CAJan93 closed this Feb 8, 2024
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.

2 participants