matrix_sdk_ui/timeline/
error.rs1use matrix_sdk::{
16 event_cache::{paginator::PaginatorError, EventCacheError},
17 room::reply::ReplyError,
18 send_queue::RoomSendQueueError,
19 HttpError,
20};
21use thiserror::Error;
22
23use crate::timeline::{pinned_events_loader::PinnedEventsLoaderError, TimelineEventItemId};
24
25#[derive(Error, Debug)]
27#[non_exhaustive]
28pub enum Error {
29 #[error("Event not found in timeline: {0:?}")]
31 EventNotInTimeline(TimelineEventItemId),
32
33 #[error("Unsupported event")]
35 UnsupportedEvent,
36
37 #[error("Invalid attachment data")]
39 InvalidAttachmentData,
40
41 #[error("Invalid attachment file name")]
43 InvalidAttachmentFileName,
44
45 #[error("Failed sending attachment")]
47 FailedSendingAttachment,
48
49 #[error("Failed toggling reaction")]
51 FailedToToggleReaction,
52
53 #[error("The room's encryption state is unknown.")]
55 UnknownEncryptionState,
56
57 #[error(transparent)]
59 EventCacheError(#[from] EventCacheError),
60
61 #[error(transparent)]
63 PaginationError(#[from] PaginationError),
64
65 #[error(transparent)]
67 PinnedEventsError(#[from] PinnedEventsLoaderError),
68
69 #[error(transparent)]
71 SendQueueError(#[from] RoomSendQueueError),
72
73 #[error(transparent)]
75 EditError(#[from] EditError),
76
77 #[error(transparent)]
79 ReplyError(#[from] ReplyError),
80
81 #[error(transparent)]
83 RedactError(#[from] RedactError),
84}
85
86#[derive(Error, Debug)]
87pub enum EditError {
88 #[error("the new content type ({new}) doesn't match that of the previous content ({original}")]
90 ContentMismatch { original: String, new: String },
91
92 #[error("Invalid state: the local echo we tried to abort has been lost.")]
94 InvalidLocalEchoState,
95
96 #[error(transparent)]
98 RoomError(#[from] matrix_sdk::room::edit::EditError),
99}
100
101#[derive(Error, Debug)]
102pub enum RedactError {
103 #[error("Event to redact wasn't found for item id {0:?}")]
105 ItemNotFound(TimelineEventItemId),
106
107 #[error(transparent)]
109 HttpError(#[from] HttpError),
110
111 #[error("Invalid state: the local echo we tried to abort has been lost.")]
113 InvalidLocalEchoState,
114}
115
116#[derive(Error, Debug)]
117pub enum PaginationError {
118 #[error("Error when paginating.")]
120 Paginator(#[source] PaginatorError),
121
122 #[error("Pagination type not supported in this focus mode")]
123 NotSupported,
124}
125
126#[derive(Debug, Error)]
127pub enum UnsupportedEditItem {
128 #[error("tried to edit a non-poll event")]
129 NotPollEvent,
130 #[error("tried to edit another user's event")]
131 NotOwnEvent,
132 #[error("event to edit not found")]
133 MissingEvent,
134}
135
136#[derive(Debug, Error)]
137pub enum SendEventError {
138 #[error(transparent)]
139 UnsupportedEditItem(#[from] UnsupportedEditItem),
140
141 #[error(transparent)]
142 RoomQueueError(#[from] RoomSendQueueError),
143}