MCPcopy
hub / github.com/apache/devlake / ApiOutputAbort

Function ApiOutputAbort

backend/server/api/shared/api_output.go:123–131  ·  view source on GitHub ↗

ApiOutputAbort writes the HTTP response code header and saves the error internally, but doesn't push it to the response

(c *gin.Context, err error)

Source from the content-addressed store, hash-verified

121
122// ApiOutputAbort writes the HTTP response code header and saves the error internally, but doesn't push it to the response
123func ApiOutputAbort(c *gin.Context, err error) {
124 if e, ok := err.(errors.Error); ok {
125 logruslog.Global.Error(err, "HTTP %d abort-error", e.GetType().GetHttpCode())
126 _ = c.AbortWithError(e.GetType().GetHttpCode(), errors.Default.New(e.Messages().Format()))
127 } else {
128 logruslog.Global.Error(err, "HTTP %d abort-error (native)", http.StatusInternalServerError)
129 _ = c.AbortWithError(http.StatusInternalServerError, err)
130 }
131}

Callers

nothing calls this directly

Calls 6

GetHttpCodeMethod · 0.80
FormatMethod · 0.80
ErrorMethod · 0.65
GetTypeMethod · 0.65
NewMethod · 0.65
MessagesMethod · 0.65

Tested by

no test coverage detected