Validate makes sure there is a error expression that matches the gRPC error expression.
()
| 25 | // Validate makes sure there is a error expression that matches the gRPC error |
| 26 | // expression. |
| 27 | func (e *GRPCErrorExpr) Validate() *eval.ValidationErrors { |
| 28 | verr := new(eval.ValidationErrors) |
| 29 | switch p := e.Response.Parent.(type) { |
| 30 | case *GRPCEndpointExpr: |
| 31 | if p.MethodExpr.Error(e.Name) == nil { |
| 32 | verr.Add(e, "Error %#v does not match an error defined in the method", e.Name) |
| 33 | } |
| 34 | case *GRPCServiceExpr: |
| 35 | if p.Error(e.Name) == nil { |
| 36 | verr.Add(e, "Error %#v does not match an error defined in the service", e.Name) |
| 37 | } |
| 38 | case *RootExpr: |
| 39 | if Root.Error(e.Name) == nil { |
| 40 | verr.Add(e, "Error %#v does not match an error defined in the API", e.Name) |
| 41 | } |
| 42 | } |
| 43 | return verr |
| 44 | } |
| 45 | |
| 46 | // Finalize looks up the corresponding method error expression. |
| 47 | func (e *GRPCErrorExpr) Finalize(a *GRPCEndpointExpr) { |