From 18e2f69e85bf7101b9d26c72e7676e4cb0dac285 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sat, 5 Oct 2024 19:14:53 +0200 Subject: [bugfix] Return 501 (not implemented) if user tries to schedule post (#3395) --- internal/gtserror/withcode.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'internal/gtserror/withcode.go') 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 -- cgit v1.2.3