buildErrorsData builds the error data for all the error responses in the endpoint expression. The response message for each error response are inferred from the method's error expression if not specified explicitly.
(e *expr.GRPCEndpointExpr, sd *ServiceData)
| 1116 | // endpoint expression. The response message for each error response are |
| 1117 | // inferred from the method's error expression if not specified explicitly. |
| 1118 | func (d *ServicesData) buildErrorsData(e *expr.GRPCEndpointExpr, sd *ServiceData) []*ErrorData { |
| 1119 | svc := sd.Service |
| 1120 | errors := make([]*ErrorData, 0, len(e.GRPCErrors)) |
| 1121 | for _, v := range e.GRPCErrors { |
| 1122 | responseData := &ResponseData{ |
| 1123 | StatusCode: statusCodeToGRPCConst(v.Response.StatusCode), |
| 1124 | Description: v.Response.Description, |
| 1125 | ServerConvert: d.buildErrorConvertData(v, e, sd, true), |
| 1126 | ClientConvert: d.buildErrorConvertData(v, e, sd, false), |
| 1127 | } |
| 1128 | errorLoc := svc.Method(e.MethodExpr.Name).ErrorLocs[v.Name] |
| 1129 | errors = append(errors, &ErrorData{ |
| 1130 | Name: v.Name, |
| 1131 | Ref: svc.Scope.GoFullTypeRef(v.AttributeExpr, pkgWithDefault(errorLoc, svc.PkgName)), |
| 1132 | Response: responseData, |
| 1133 | }) |
| 1134 | } |
| 1135 | return errors |
| 1136 | } |
| 1137 | |
| 1138 | func (d *ServicesData) buildErrorConvertData(ge *expr.GRPCErrorExpr, e *expr.GRPCEndpointExpr, sd *ServiceData, svr bool) *ConvertData { |
| 1139 | // No need to build transformation functions for default error or non-object |
no test coverage detected