MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / buildErrorResponse

Function buildErrorResponse

pkg/controller/invoke.go:82–97  ·  view source on GitHub ↗
(ctx *InvokeContext, err error)

Source from the content-addressed store, hash-verified

80}
81
82func buildErrorResponse(ctx *InvokeContext, err error) {
83 var status int
84 if ctx.RunOptions.RecommendedOptions.Features.EnableMetrics {
85 defer func() {
86 ctx.Logger.V(9).Infof("user function response code %d", status)
87 ctx.Metrics.SetLabel(responseCodeLabel, strconv.Itoa(status))
88 }()
89 }
90
91 finalErr := innerErr.GenericKunFinalError(err)
92 ctx.Response.SetStatusCode(finalErr.Status)
93 status = finalErr.Status
94 ctx.Response.SetHeader(api.XBceFunctionError, "Unhandled")
95 errMsg := finalErr.Error()
96 ctx.Response.SetBody([]byte(errMsg))
97}
98
99func parseBrn(ctx *InvokeContext) (brn.BRN, error) {
100 if functionBRN, err := brn.Parse(ctx.FunctionBRN); err != nil {

Callers 1

DoMethod · 0.85

Calls 7

InfofMethod · 0.80
VMethod · 0.80
SetLabelMethod · 0.80
SetStatusCodeMethod · 0.45
SetHeaderMethod · 0.45
ErrorMethod · 0.45
SetBodyMethod · 0.45

Tested by

no test coverage detected