代码拉取完成,页面将自动刷新
package expr
import (
"goa.design/goa/eval"
)
type (
// HTTPErrorExpr defines a HTTP error response including its name,
// status, headers and result type.
HTTPErrorExpr struct {
// ErrorExpr is the underlying goa design error expression.
*ErrorExpr
// Name of error, we need a separate copy of the name to match it
// up with the appropriate ErrorExpr.
Name string
// Response is the corresponding HTTP response.
Response *HTTPResponseExpr
}
)
// EvalName returns the generic definition name used in error messages.
func (e *HTTPErrorExpr) EvalName() string {
return "HTTP error " + e.Name
}
// Validate makes sure there is a error expression that matches the HTTP error
// expression.
func (e *HTTPErrorExpr) Validate() *eval.ValidationErrors {
verr := new(eval.ValidationErrors)
switch p := e.Response.Parent.(type) {
case *HTTPEndpointExpr:
if p.MethodExpr.Error(e.Name) == nil {
verr.Add(e, "Error %#v does not match an error defined in the method", e.Name)
}
case *HTTPServiceExpr:
if p.Error(e.Name) == nil {
verr.Add(e, "Error %#v does not match an error defined in the service", e.Name)
}
case *RootExpr:
if Root.Error(e.Name) == nil {
verr.Add(e, "Error %#v does not match an error defined in the API", e.Name)
}
}
return verr
}
// Finalize looks up the corresponding method error expression.
func (e *HTTPErrorExpr) Finalize(a *HTTPEndpointExpr) {
var ee *ErrorExpr
switch p := e.Response.Parent.(type) {
case *HTTPEndpointExpr:
ee = p.MethodExpr.Error(e.Name)
case *HTTPServiceExpr:
ee = p.Error(e.Name)
case *RootExpr:
ee = Root.Error(e.Name)
}
e.ErrorExpr = ee
e.Response.Finalize(a, e.AttributeExpr)
if e.Response.Body == nil {
e.Response.Body = httpErrorResponseBody(a, e)
}
// Initialize response content type if result is media type.
if e.Response.Body.Type == Empty {
return
}
if e.Response.ContentType != "" {
return
}
mt, ok := e.Response.Body.Type.(*ResultTypeExpr)
if !ok {
return
}
e.Response.ContentType = mt.Identifier
}
// Dup creates a copy of the error expression.
func (e *HTTPErrorExpr) Dup() *HTTPErrorExpr {
return &HTTPErrorExpr{
ErrorExpr: e.ErrorExpr,
Name: e.Name,
Response: e.Response.Dup(),
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。