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

Function httpOrJSONRPCError

dsl/response.go:288–315  ·  view source on GitHub ↗
(n string, p eval.Expression, args ...any)

Source from the content-addressed store, hash-verified

286}
287
288func httpOrJSONRPCError(n string, p eval.Expression, args ...any) *expr.HTTPErrorExpr {
289 if len(args) == 0 {
290 eval.TooFewArgError()
291 return nil
292 }
293 var (
294 code int
295 fn func()
296 val any
297 )
298 val = args[0]
299 args = args[1:]
300 code, fn = parseResponseArgs(val, args...)
301 if code == 0 {
302 code = expr.StatusBadRequest
303 }
304 resp := &expr.HTTPResponseExpr{
305 StatusCode: code,
306 Parent: p,
307 }
308 if fn != nil {
309 eval.Execute(fn, resp)
310 }
311 return &expr.HTTPErrorExpr{
312 Name: n,
313 Response: resp,
314 }
315}

Callers 1

ResponseFunction · 0.85

Calls 3

TooFewArgErrorFunction · 0.92
ExecuteFunction · 0.92
parseResponseArgsFunction · 0.85

Tested by

no test coverage detected