| 80 | } |
| 81 | |
| 82 | func 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 | |
| 99 | func parseBrn(ctx *InvokeContext) (brn.BRN, error) { |
| 100 | if functionBRN, err := brn.Parse(ctx.FunctionBRN); err != nil { |