MCPcopy
hub / github.com/nats-io/nats.go / ExampleRequest_Error

Function ExampleRequest_Error

micro/example_test.go:358–368  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

356}
357
358func ExampleRequest_Error() {
359 handler := func(req micro.Request) {
360 // respond with an error
361 // Error sets Nats-Service-Error and Nats-Service-Error-Code headers in the response
362 if err := req.Error("400", "bad request", []byte(`{"error": "value should be a number"}`)); err != nil {
363 log.Fatal(err)
364 }
365 }
366
367 fmt.Printf("%T", handler)
368}

Callers

nothing calls this directly

Calls 1

ErrorMethod · 0.65

Tested by

no test coverage detected