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

Need better way of parsing/catching specific errors? #41

Open
benguild opened this issue Sep 11, 2024 · 1 comment
Open

Need better way of parsing/catching specific errors? #41

benguild opened this issue Sep 11, 2024 · 1 comment

Comments

@benguild
Copy link

It seems like the only way to catch stuff like this is with string comparison:

if err != nil && strings.HasPrefix(err.Error(), "[ERROR]: Invalid `to` field.") {
    // cancel, etc.
}

… Am I missing something here? If not, it feels a bit delicate.

For example, if the API rejects a bad email address, we want to be able to catch that specific error.

@drish
Copy link
Collaborator

drish commented Sep 16, 2024

hi @benguild, that's a good point, currently the SDK doesn't provide a way to catch specific errors, so you end up having to using something like HasPrefix.
I have recently started working back again on adding all error types for all categories, see here, these errors should e caught by errors.Is, you can expect a release that covers this sometime in the next coming weeks.

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

2 participants