osrg/gobgp

Consider using grpc error codes for grpc API responses

jvgutierrez opened this issue · 1 comments

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!

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