diff options
Diffstat (limited to 'internal/gtserror/error.go')
-rw-r--r-- | internal/gtserror/error.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/gtserror/error.go b/internal/gtserror/error.go index a39b5475c..bd83a8dc8 100644 --- a/internal/gtserror/error.go +++ b/internal/gtserror/error.go @@ -40,8 +40,22 @@ const ( notRelevantKey spamKey notPermittedKey + limitReachedKey ) +// LimitReached indicates that this error was caused by +// some kind of limit being reached, e.g. media upload limit. +func LimitReached(err error) bool { + _, ok := errors.Value(err, limitReachedKey).(struct{}) + return ok +} + +// SetLimitReached will wrap the given error to store a "limit reached" +// flag, returning wrapped error. See LimitReached() for example use-cases. +func SetLimitReached(err error) error { + return errors.WithValue(err, limitReachedKey, struct{}{}) +} + // IsUnretrievable indicates that a call to retrieve a resource // (account, status, attachment, etc) could not be fulfilled, either // because it was not found locally, or because some prerequisite |