(val any, args ...any)
| 257 | } |
| 258 | |
| 259 | func parseResponseArgs(val any, args ...any) (code int, fn func()) { |
| 260 | switch t := val.(type) { |
| 261 | case int: |
| 262 | code = t |
| 263 | if len(args) > 1 { |
| 264 | eval.TooManyArgError() |
| 265 | return |
| 266 | } |
| 267 | if len(args) == 1 { |
| 268 | if d, ok := args[0].(func()); ok { |
| 269 | fn = d |
| 270 | } else { |
| 271 | eval.InvalidArgError("function", args[0]) |
| 272 | return |
| 273 | } |
| 274 | } |
| 275 | case func(): |
| 276 | if len(args) > 0 { |
| 277 | eval.TooManyArgError() |
| 278 | return |
| 279 | } |
| 280 | fn = t |
| 281 | default: |
| 282 | eval.InvalidArgError("int (HTTP status code) or function", val) |
| 283 | return |
| 284 | } |
| 285 | return |
| 286 | } |
| 287 | |
| 288 | func httpOrJSONRPCError(n string, p eval.Expression, args ...any) *expr.HTTPErrorExpr { |
| 289 | if len(args) == 0 { |
no test coverage detected