MCPcopy Create free account
hub / github.com/gotenberg/gotenberg / httpErrorHandler

Function httpErrorHandler

pkg/modules/api/middlewares.go:92–104  ·  view source on GitHub ↗

httpErrorHandler is the centralized HTTP error handler. It parses the error, returns a response as "text/plain; charset=UTF-8".

()

Source from the content-addressed store, hash-verified

90// httpErrorHandler is the centralized HTTP error handler. It parses the error,
91// returns a response as "text/plain; charset=UTF-8".
92func httpErrorHandler() echo.HTTPErrorHandler {
93 return func(err error, c echo.Context) {
94 logger := c.Get("logger").(*slog.Logger)
95 status, message := ParseError(err)
96
97 c.Response().Header().Add(echo.HeaderContentType, echo.MIMETextPlainCharsetUTF8)
98
99 err = c.String(status, message)
100 if err != nil {
101 logger.ErrorContext(c.Request().Context(), fmt.Sprintf("send error response: %s", err.Error()))
102 }
103 }
104}
105
106// latencyMiddleware sets the start time in the [echo.Context] under
107// "startTime". Its value will be used later to calculate request latency.

Callers 1

StartMethod · 0.85

Calls 6

ParseErrorFunction · 0.85
GetMethod · 0.80
AddMethod · 0.80
StringMethod · 0.80
RequestMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected