MCPcopy Create free account
hub / github.com/cli/cli / WriteError

Function WriteError

internal/barista/observability/telemetry.twirp.go:591–593  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)
591func 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.
596func writeError(ctx context.Context, resp http.ResponseWriter, err error, hooks *twirp.ServerHooks) {

Callers

nothing calls this directly

Calls 1

writeErrorFunction · 0.85

Tested by

no test coverage detected