diff options
author | 2024-10-05 19:14:53 +0200 | |
---|---|---|
committer | 2024-10-05 19:14:53 +0200 | |
commit | 18e2f69e85bf7101b9d26c72e7676e4cb0dac285 (patch) | |
tree | c4f82494a63ee57108547b214ecbcbb3db002691 /internal/gtserror/withcode.go | |
parent | [chore] Change order of error checking after PostInbox (#3394) (diff) | |
download | gotosocial-18e2f69e85bf7101b9d26c72e7676e4cb0dac285.tar.xz |
[bugfix] Return 501 (not implemented) if user tries to schedule post (#3395)
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 da489225c..0878db7bc 100644 --- a/internal/gtserror/withcode.go +++ b/internal/gtserror/withcode.go @@ -191,6 +191,19 @@ func NewErrorGone(original error, helpText ...string) WithCode { } } +// NewErrorNotImplemented returns an ErrorWithCode 501 with the given original error and optional help text. +func NewErrorNotImplemented(original error, helpText ...string) WithCode { + safe := http.StatusText(http.StatusNotImplemented) + if helpText != nil { + safe = safe + ": " + strings.Join(helpText, ": ") + } + return withCode{ + original: original, + safe: errors.New(safe), + code: http.StatusNotImplemented, + } +} + // NewErrorClientClosedRequest returns an ErrorWithCode 499 with the given original error. // This error type should only be used when an http caller has already hung up their request. // See: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#nginx |