matrix_sdk_ui/timeline/
error.rs1use matrix_sdk::{
16 HttpError, event_cache::EventCacheError, paginators::PaginatorError, room::reply::ReplyError,
17 send_queue::RoomSendQueueError,
18};
19use thiserror::Error;
20
21use crate::timeline::TimelineEventItemId;
22
23#[derive(Error, Debug)]
25#[non_exhaustive]
26pub enum Error {
27 #[error("Event not found in timeline: {0:?}")]
29 EventNotInTimeline(TimelineEventItemId),
30
31 #[error("Unsupported event")]
33 UnsupportedEvent,
34
35 #[error("Invalid attachment data")]
37 InvalidAttachmentData,
38
39 #[error("Invalid attachment file name")]
41 InvalidAttachmentFileName,
42
43 #[error("Failed sending attachment")]
45 FailedSendingAttachment,
46
47 #[error("Failed toggling reaction")]
49 FailedToToggleReaction,
50
51 #[error("The room's encryption state is unknown.")]
53 UnknownEncryptionState,
54
55 #[error(transparent)]
57 EventCacheError(#[from] EventCacheError),
58
59 #[error(transparent)]
61 PaginationError(#[from] PaginationError),
62
63 #[error(transparent)]
65 SendQueueError(#[from] RoomSendQueueError),
66
67 #[error(transparent)]
69 EditError(#[from] EditError),
70
71 #[error(transparent)]
73 ReplyError(#[from] ReplyError),
74
75 #[error(transparent)]
77 RedactError(#[from] RedactError),
78}
79
80#[derive(Error, Debug)]
81pub enum EditError {
82 #[error("the new content type ({new}) doesn't match that of the previous content ({original}")]
84 ContentMismatch { original: String, new: String },
85
86 #[error("Invalid state: the local echo we tried to abort has been lost.")]
88 InvalidLocalEchoState,
89
90 #[error(transparent)]
92 RoomError(#[from] matrix_sdk::room::edit::EditError),
93}
94
95#[derive(Error, Debug)]
96pub enum RedactError {
97 #[error("Event to redact wasn't found for item id {0:?}")]
99 ItemNotFound(TimelineEventItemId),
100
101 #[error(transparent)]
103 HttpError(#[from] HttpError),
104
105 #[error("Invalid state: the local echo we tried to abort has been lost.")]
107 InvalidLocalEchoState,
108}
109
110#[derive(Error, Debug)]
111pub enum PaginationError {
112 #[error("Error when paginating.")]
114 Paginator(#[source] PaginatorError),
115
116 #[error("Pagination type not supported in this focus mode")]
117 NotSupported,
118}
119
120#[derive(Debug, Error)]
121pub enum UnsupportedEditItem {
122 #[error("tried to edit a non-poll event")]
123 NotPollEvent,
124 #[error("tried to edit another user's event")]
125 NotOwnEvent,
126 #[error("event to edit not found")]
127 MissingEvent,
128}
129
130#[derive(Debug, Error)]
131pub enum SendEventError {
132 #[error(transparent)]
133 UnsupportedEditItem(#[from] UnsupportedEditItem),
134
135 #[error(transparent)]
136 RoomQueueError(#[from] RoomSendQueueError),
137}