You've already forked imgproxy
mirror of
https://github.com/imgproxy/imgproxy.git
synced 2026-04-24 19:54:05 +02:00
69c7d2f117
* IMG-76: new linter config & fixes * Upgrade golangci-lint to 2.7.2
28 lines
701 B
Go
28 lines
701 B
Go
package errctx
|
|
|
|
// TextError is an implementation of [Error] that holds a simple text message.
|
|
//
|
|
// When implementing a custom error type that does not wrap another error,
|
|
// embed [TextError] to provide standard behavior.
|
|
type TextError struct {
|
|
*ErrorContext
|
|
|
|
msg string
|
|
}
|
|
|
|
// NewTextError creates a new [TextError] with the given message and options.
|
|
func NewTextError(msg string, stackSkip int, opts ...Option) *TextError {
|
|
return &TextError{
|
|
msg: msg,
|
|
ErrorContext: newErrorContext(stackSkip+1, opts...),
|
|
}
|
|
}
|
|
|
|
// Error returns the error message with prefix if set.
|
|
func (e *TextError) Error() string {
|
|
if len(e.prefix) > 0 {
|
|
return e.prefix + ": " + e.msg
|
|
}
|
|
return e.msg
|
|
}
|