MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / NewError

Function NewError

server/errors.go:38–53  ·  view source on GitHub ↗

NewError creates a new [Error] instance wrapping the given errctx.Error and category. If err is nil, it returns nil. If the error or any of its causes is [context.DeadlineExceeded] or [context.Canceled], the category is set to "timeout" regardless of the provided category.

(err errctx.Error, category string)

Source from the content-addressed store, hash-verified

36// If the error or any of its causes is [context.DeadlineExceeded] or [context.Canceled],
37// the category is set to "timeout" regardless of the provided category.
38func NewError(err errctx.Error, category string) *Error {
39 if err == nil {
40 return nil
41 }
42
43 // If the error or any of its causes is context.DeadlineExceeded or context.Canceled,
44 // enforce the timeout category.
45 if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) {
46 category = errCategoryTimeout
47 }
48
49 return &Error{
50 Err: err,
51 Category: category,
52 }
53}
54
55func newRouteNotDefinedError(path string) errctx.Error {
56 return RouteNotDefinedError{errctx.NewTextError(

Callers 8

wrapErrorMethod · 0.92
newRequestMethod · 0.92
executeMethod · 0.92
writeDebugHeadersMethod · 0.92
respondWithImageMethod · 0.92
TestIntoWithErrorMethod · 0.92
WithSecretMethod · 0.85
WithPanicMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestIntoWithErrorMethod · 0.74