mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 02:12:25 -05:00
[bugfix] fix media limit reader check (#3363)
* return nicer errors for frontend when media / emoji upload limit reached * fix reader limit check * add code comment
This commit is contained in:
parent
c1c8849322
commit
497ebd8c4e
3 changed files with 37 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue