summaryrefslogtreecommitdiff
path: root/internal/gtserror/withcode.go
diff options
context:
space:
mode:
authorLibravatar tsmethurst <tobi.smethurst@protonmail.com>2022-01-15 17:36:15 +0100
committerLibravatar tsmethurst <tobi.smethurst@protonmail.com>2022-01-15 17:36:15 +0100
commit6bf39d0fc1286bdf2f4760adab52c6eff234d01d (patch)
treee4916598a7a14eab4336909c5fec1de6ed8ad0d4 /internal/gtserror/withcode.go
parentstart fixing up emoji processing code (diff)
downloadgotosocial-6bf39d0fc1286bdf2f4760adab52c6eff234d01d.tar.xz
emoji code passing muster
Diffstat (limited to 'internal/gtserror/withcode.go')
-rw-r--r--internal/gtserror/withcode.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/gtserror/withcode.go b/internal/gtserror/withcode.go
index a00cc8503..34889b961 100644
--- a/internal/gtserror/withcode.go
+++ b/internal/gtserror/withcode.go
@@ -122,3 +122,16 @@ func NewErrorInternalError(original error, helpText ...string) WithCode {
code: http.StatusInternalServerError,
}
}
+
+// NewErrorConflict returns an ErrorWithCode 409 with the given original error and optional help text.
+func NewErrorConflict(original error, helpText ...string) WithCode {
+ safe := "conflict"
+ if helpText != nil {
+ safe = safe + ": " + strings.Join(helpText, ": ")
+ }
+ return withCode{
+ original: original,
+ safe: errors.New(safe),
+ code: http.StatusConflict,
+ }
+}