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

Function unwrapErrorChain

server/error_page.go:65–87  ·  view source on GitHub ↗

unwrapErrorChain traverses the error chain using errors.Unwrap and returns all error types and messages from the outermost wrapper to the root cause.

(err error)

Source from the content-addressed store, hash-verified

63// unwrapErrorChain traverses the error chain using errors.Unwrap and returns
64// all error types and messages from the outermost wrapper to the root cause.
65func unwrapErrorChain(err error) []errorChainItem {
66 var chain []errorChainItem
67
68 for err != nil {
69 var url string
70
71 //nolint:errorlint
72 if e, ok := err.(errctx.Error); ok {
73 url = e.DocsURL()
74 }
75
76 chain = append(chain, errorChainItem{
77 Type: errorTypeReplacer.Replace(errctx.ErrorType(err)),
78 Message: err.Error(),
79 StackTrace: buildStackTrace(err),
80 DocsURL: url,
81 })
82
83 err = errors.Unwrap(err)
84 }
85
86 return chain
87}
88
89// buildStackTrace gets the stack trace from the outermost error and marks
90// which frames correspond to which errors in the chain.

Callers 1

generateErrorHTMLFunction · 0.85

Calls 5

ErrorTypeFunction · 0.92
buildStackTraceFunction · 0.85
DocsURLMethod · 0.65
ErrorMethod · 0.65
UnwrapMethod · 0.45

Tested by

no test coverage detected