2026-05-24 13:58:12 -04:00
|
|
|
package requests
|
|
|
|
|
|
|
|
|
|
import "errors"
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
ErrInvalidMediaType = errors.New("invalid media type")
|
|
|
|
|
ErrInvalidInput = errors.New("invalid request input")
|
|
|
|
|
ErrRequestsDisabled = errors.New("requests are disabled")
|
|
|
|
|
ErrUserBlocked = errors.New("user is blocked from requesting")
|
|
|
|
|
ErrQuotaExceeded = errors.New("request quota exceeded")
|
|
|
|
|
ErrAlreadyAvailable = errors.New("media is already available")
|
|
|
|
|
ErrAlreadyRequested = errors.New("media is already requested")
|
|
|
|
|
ErrNotFound = errors.New("request not found")
|
|
|
|
|
ErrForbidden = errors.New("request forbidden")
|
|
|
|
|
ErrInvalidState = errors.New("invalid request state")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type QuotaError struct {
|
|
|
|
|
Used int
|
|
|
|
|
Limit int
|
|
|
|
|
WindowDays int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e QuotaError) Error() string {
|
|
|
|
|
return ErrQuotaExceeded.Error()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e QuotaError) Unwrap() error {
|
|
|
|
|
return ErrQuotaExceeded
|
|
|
|
|
}
|
2026-06-09 13:00:48 -04:00
|
|
|
|
|
|
|
|
// ValidationError carries plugin Validate results back to the API layer.
|
|
|
|
|
type ValidationError struct {
|
|
|
|
|
FieldErrors map[string]string
|
|
|
|
|
FormError string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e *ValidationError) Error() string {
|
|
|
|
|
if e.FormError != "" {
|
|
|
|
|
return e.FormError
|
|
|
|
|
}
|
|
|
|
|
return "validation failed"
|
|
|
|
|
}
|