MCPcopy Index your code
hub / github.com/Shopify/toxiproxy / apiError

Method apiError

api.go:521–540  ·  view source on GitHub ↗
(resp http.ResponseWriter, err error)

Source from the content-addressed store, hash-verified

519)
520
521func (server *ApiServer) apiError(resp http.ResponseWriter, err error) bool {
522 obj, ok := err.(*ApiError)
523 if !ok && err != nil {
524 server.Logger.Warn().Err(err).Msg("Error did not include status code")
525 obj = &ApiError{err.Error(), http.StatusInternalServerError}
526 }
527
528 if obj == nil {
529 return false
530 }
531
532 data, err2 := json.Marshal(obj)
533 if err2 != nil {
534 server.Logger.Warn().Err(err2).Msg("Error json encoding error (╯°□°)╯︵ ┻━┻ ")
535 }
536 resp.Header().Set("Content-Type", "application/json")
537 http.Error(resp, string(data), obj.StatusCode)
538
539 return true
540}
541
542type proxyToxics struct {
543 *Proxy

Callers 12

ProxyIndexMethod · 0.95
ResetStateMethod · 0.95
ProxyCreateMethod · 0.95
PopulateMethod · 0.95
ProxyShowMethod · 0.95
ProxyUpdateMethod · 0.95
ProxyDeleteMethod · 0.95
ToxicIndexMethod · 0.95
ToxicCreateMethod · 0.95
ToxicShowMethod · 0.95
ToxicUpdateMethod · 0.95
ToxicDeleteMethod · 0.95

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected