1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-12-23 22:11:10 +02:00
Files
imgproxy/errctx/error.go
Victor Sokolov 69c7d2f117 IMG-76: new linter config & fixes (#1587)
* IMG-76: new linter config & fixes

* Upgrade golangci-lint to 2.7.2
2025-12-10 13:46:22 +01:00

41 lines
1.3 KiB
Go

package errctx
import "reflect"
// Error is an interface for errors that carry additional context information.
type Error interface {
// Error returns the error message.
Error() string
// StatusCode returns the HTTP status code associated with the error.
StatusCode() int
// PublicMessage returns the public message associated with the error.
PublicMessage() string
// ShouldReport indicates whether the error should be reported.
ShouldReport() bool
// StackTrace returns the stack trace associated with the error.
// This method is traditionally used to retrieve the stack trace
// by packages like error reporters.
StackTrace() []uintptr
// Callers returns the stack trace associated with the error.
// This method is traditionally used to retrieve the stack trace
// by packages like error reporters.
Callers() []uintptr
// FormatStack returns the stack trace as a formatted string.
FormatStack() string
// CloneErrorContext returns a copy of the error context
// with applied options.
CloneErrorContext(opts ...Option) *ErrorContext
}
// ErrorType returns the type name of the given error.
// If the error is [WrappedError], it returns the type of the inner error.
func ErrorType(err error) string {
if ew, ok := err.(*WrappedError); ok {
return ErrorType(ew.Unwrap())
}
return reflect.TypeOf(err).String()
}