summaryrefslogtreecommitdiffstats
path: root/models/error.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/error.go')
-rw-r--r--models/error.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go
index 7370bd1571..3b05a7152c 100644
--- a/models/error.go
+++ b/models/error.go
@@ -85,6 +85,28 @@ func (err ErrSSHDisabled) Error() string {
return "SSH is disabled"
}
+// ErrCancelled represents an error due to context cancellation
+type ErrCancelled struct {
+ Message string
+}
+
+// IsErrCancelled checks if an error is a ErrCancelled.
+func IsErrCancelled(err error) bool {
+ _, ok := err.(ErrCancelled)
+ return ok
+}
+
+func (err ErrCancelled) Error() string {
+ return "Cancelled: " + err.Message
+}
+
+// ErrCancelledf returns an ErrCancelled for the provided format and args
+func ErrCancelledf(format string, args ...interface{}) error {
+ return ErrCancelled{
+ fmt.Sprintf(format, args...),
+ }
+}
+
// ____ ___
// | | \______ ___________
// | | / ___// __ \_ __ \