Finalize looks up the corresponding method error expression.
(a *HTTPEndpointExpr)
| 87 | |
| 88 | // Finalize looks up the corresponding method error expression. |
| 89 | func (e *HTTPErrorExpr) Finalize(a *HTTPEndpointExpr) { |
| 90 | var ee *ErrorExpr |
| 91 | switch p := e.Response.Parent.(type) { |
| 92 | case *HTTPEndpointExpr: |
| 93 | ee = p.MethodExpr.Error(e.Name) |
| 94 | case *HTTPServiceExpr: |
| 95 | ee = p.Error(e.Name) |
| 96 | case *RootExpr: |
| 97 | ee = Root.Error(e.Name) |
| 98 | } |
| 99 | e.ErrorExpr = ee |
| 100 | e.Response.Finalize(a, e.AttributeExpr) |
| 101 | if e.Response.Body == nil { |
| 102 | e.Response.Body = httpErrorResponseBody(a, e) |
| 103 | e.Response.Body.Finalize() |
| 104 | } |
| 105 | // map any unmapped attributes in ErrorResult type to response headers |
| 106 | e.Response.mapUnmappedAttrs(e.AttributeExpr) |
| 107 | |
| 108 | // Initialize response content type if result is media type. |
| 109 | if e.Response.Body.Type == Empty { |
| 110 | return |
| 111 | } |
| 112 | if e.Response.ContentType != "" { |
| 113 | return |
| 114 | } |
| 115 | mt, ok := e.Response.Body.Type.(*ResultTypeExpr) |
| 116 | if !ok { |
| 117 | return |
| 118 | } |
| 119 | e.Response.ContentType = mt.Identifier |
| 120 | } |
| 121 | |
| 122 | // Dup creates a copy of the error expression. |
| 123 | func (e *HTTPErrorExpr) Dup() *HTTPErrorExpr { |
nothing calls this directly
no test coverage detected