rive_models/
error.rs

1use serde::Deserialize;
2
3use crate::permission::{Permission, UserPermission};
4
5/// A representation of an API error.
6///
7/// Please consider importing this type as `rive_models::error::ApiError`
8/// instead of `rive_models::ApiError` as this export is deprecated and
9/// will be removed in next major release.
10#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11#[serde(tag = "type")]
12pub enum ApiError {
13    LabelMe,
14
15    // Onboarding related errors
16    AlreadyOnboarded,
17
18    // User related errors
19    UsernameTaken,
20    InvalidUsername,
21    UnknownUser,
22    AlreadyFriends,
23    AlreadySentRequest,
24    Blocked,
25    BlockedByOther,
26    NotFriends,
27
28    // Channel related errors
29    UnknownChannel,
30    UnknownAttachment,
31    UnknownMessage,
32    CannotEditMessage,
33    CannotJoinCall,
34    TooManyAttachments,
35    TooManyReplies,
36    EmptyMessage,
37    PayloadTooLarge,
38    CannotRemoveYourself,
39    GroupTooLarge { max: usize },
40    AlreadyInGroup,
41    NotInGroup,
42
43    // Server related errors
44    UnknownServer,
45    InvalidRole,
46    Banned,
47    TooManyServers { max: usize },
48    TooManyEmoji,
49
50    // Bot related errors
51    ReachedMaximumBots,
52    IsBot,
53    BotIsPrivate,
54
55    // Permission errors
56    MissingPermission { permission: Permission },
57    MissingUserPermission { permission: UserPermission },
58    NotElevated,
59    CannotGiveMissingPermissions,
60    NotOwner,
61
62    // General errors
63    DatabaseError { operation: String, with: String },
64    InternalError,
65    InvalidOperation,
66    InvalidCredentials,
67    InvalidSession,
68    DuplicateNonce,
69    VosoUnavailable,
70    NotFound,
71    NoEffect,
72    FailedValidation,
73
74    // Other errors that API does not return but it's still API related things
75    Unauthenticated,
76}
77
78/// Revolt file storage API error
79#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
80#[serde(tag = "type")]
81pub enum AutumnError {
82    FileTooLarge { max_size: usize },
83    FileTypeNotAllowed,
84    FailedToReceive,
85    BlockingError,
86    DatabaseError,
87    MissingData,
88    UnknownTag,
89    ProbeError,
90    NotFound,
91    Malware,
92    IOError,
93    S3Error,
94    LabelMe,
95}