summaryrefslogtreecommitdiff
path: root/internal/gtserror/withcode.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/gtserror/withcode.go')
-rw-r--r--internal/gtserror/withcode.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/gtserror/withcode.go b/internal/gtserror/withcode.go
index 55fe7502a..d17a4e42e 100644
--- a/internal/gtserror/withcode.go
+++ b/internal/gtserror/withcode.go
@@ -198,3 +198,14 @@ func NewErrorClientClosedRequest(original error) WithCode {
code: StatusClientClosedRequest,
}
}
+
+// NewErrorRequestTimeout returns an ErrorWithCode 408 with the given original error.
+// This error type should only be used when the server has decided to hang up a client
+// request after x amount of time, to avoid keeping extremely slow client requests open.
+func NewErrorRequestTimeout(original error) WithCode {
+ return withCode{
+ original: original,
+ safe: errors.New(http.StatusText(http.StatusRequestTimeout)),
+ code: http.StatusRequestTimeout,
+ }
+}