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

Consider using grpc error codes for grpc API responses #2837

Open
jvgutierrez opened this issue Sep 27, 2024 · 1 comment
Open

Consider using grpc error codes for grpc API responses #2837

jvgutierrez opened this issue Sep 27, 2024 · 1 comment

Comments

@jvgutierrez
Copy link

Hi, I've realized that gobgp grpc API doesn't make use of grpc status codes when returning errors, so clients need to parse the status message string to be able which kind of error received instead of just checking the status code.

So instead of

    if _, err := client.DeletePolicy(ctx, policyRequest); status.Code(err) != codes.NotFound {
        // handle error
    }   

The client needs to check the status string:

    if _, err := client.DeletePolicy(ctx, policyRequest); err != nil {
        s, ok := status.FromError(err)
        if !ok || !strings.HasPrefix(s.Message(), "not found") {
            // handle error
        }
    }

Would it be feasible to adopt grpc status codes? Thanks!

@SkalaNetworks
Copy link
Contributor

Is that an API breaking change with the need for a rollout of a v4?

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