MCPcopy Create free account
hub / github.com/goadesign/goa / buildErrorsData

Method buildErrorsData

grpc/codegen/service_data.go:1118–1136  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1116// endpoint expression. The response message for each error response are
1117// inferred from the method's error expression if not specified explicitly.
1118func (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
1138func (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

Callers 1

analyzeMethod · 0.95

Calls 5

buildErrorConvertDataMethod · 0.95
statusCodeToGRPCConstFunction · 0.85
GoFullTypeRefMethod · 0.80
pkgWithDefaultFunction · 0.70
MethodMethod · 0.65

Tested by

no test coverage detected