diff options
Diffstat (limited to 'internal/gtserror/withcode.go')
-rw-r--r-- | internal/gtserror/withcode.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/gtserror/withcode.go b/internal/gtserror/withcode.go index 6672000dc..ddf9371ac 100644 --- a/internal/gtserror/withcode.go +++ b/internal/gtserror/withcode.go @@ -161,3 +161,16 @@ func NewErrorUnprocessableEntity(original error, helpText ...string) WithCode { code: http.StatusUnprocessableEntity, } } + +// NewErrorGone returns an ErrorWithCode 410 with the given original error and optional help text. +func NewErrorGone(original error, helpText ...string) WithCode { + safe := http.StatusText(http.StatusGone) + if helpText != nil { + safe = safe + ": " + strings.Join(helpText, ": ") + } + return withCode{ + original: original, + safe: errors.New(safe), + code: http.StatusGone, + } +} |