WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)
(resp http.ResponseWriter, err error)
| 589 | // Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. |
| 590 | // If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err) |
| 591 | func WriteError(resp http.ResponseWriter, err error) { |
| 592 | writeError(context.Background(), resp, err, nil) |
| 593 | } |
| 594 | |
| 595 | // writeError writes Twirp errors in the response and triggers hooks. |
| 596 | func writeError(ctx context.Context, resp http.ResponseWriter, err error, hooks *twirp.ServerHooks) { |
nothing calls this directly
no test coverage detected