matrix_sdk_ui/timeline/
error.rs1use matrix_sdk::{
16 event_cache::{paginator::PaginatorError, EventCacheError},
17 send_queue::RoomSendQueueError,
18 HttpError,
19};
20use thiserror::Error;
21
22use crate::timeline::{pinned_events_loader::PinnedEventsLoaderError, TimelineEventItemId};
23
24#[derive(Error, Debug)]
26#[non_exhaustive]
27pub enum Error {
28 #[error("Event not found in timeline: {0:?}")]
30 EventNotInTimeline(TimelineEventItemId),
31
32 #[error("Unsupported event")]
34 UnsupportedEvent,
35
36 #[error("Invalid attachment data")]
38 InvalidAttachmentData,
39
40 #[error("Invalid attachment file name")]
42 InvalidAttachmentFileName,
43
44 #[error("Failed sending attachment")]
46 FailedSendingAttachment,
47
48 #[error("Failed toggling reaction")]
50 FailedToToggleReaction,
51
52 #[error("The room's encryption state is unknown.")]
54 UnknownEncryptionState,
55
56 #[error(transparent)]
58 EventCacheError(#[from] EventCacheError),
59
60 #[error(transparent)]
62 PaginationError(#[from] PaginationError),
63
64 #[error(transparent)]
66 PinnedEventsError(#[from] PinnedEventsLoaderError),
67
68 #[error(transparent)]
70 SendQueueError(#[from] RoomSendQueueError),
71
72 #[error(transparent)]
74 EditError(#[from] EditError),
75
76 #[error(transparent)]
78 RedactError(#[from] RedactError),
79}
80
81#[derive(Error, Debug)]
82pub enum EditError {
83 #[error("the new content type ({new}) doesn't match that of the previous content ({original}")]
85 ContentMismatch { original: String, new: String },
86
87 #[error("Invalid state: the local echo we tried to abort has been lost.")]
89 InvalidLocalEchoState,
90
91 #[error(transparent)]
93 RoomError(#[from] matrix_sdk::room::edit::EditError),
94}
95
96#[derive(Error, Debug)]
97pub enum RedactError {
98 #[error("Event to redact wasn't found for item id {0:?}")]
100 ItemNotFound(TimelineEventItemId),
101
102 #[error(transparent)]
104 HttpError(#[from] HttpError),
105
106 #[error("Invalid state: the local echo we tried to abort has been lost.")]
108 InvalidLocalEchoState,
109}
110
111#[derive(Error, Debug)]
112pub enum PaginationError {
113 #[error("The timeline isn't in the event focus mode")]
115 NotEventFocusMode,
116
117 #[error("Error when paginating.")]
119 Paginator(#[source] PaginatorError),
120}
121
122#[derive(Debug, Error)]
123pub enum UnsupportedReplyItem {
124 #[error("local messages whose event ID is not known can't be replied to currently")]
125 MissingEventId,
126 #[error("redacted events whose JSON form isn't available can't be replied")]
127 MissingJson,
128 #[error("event to reply to not found")]
129 MissingEvent,
130 #[error("failed to deserialize event to reply to")]
131 FailedToDeserializeEvent,
132 #[error("tried to reply to a state event")]
133 StateEvent,
134}
135
136#[derive(Debug, Error)]
137pub enum UnsupportedEditItem {
138 #[error("tried to edit a non-poll event")]
139 NotPollEvent,
140 #[error("tried to edit another user's event")]
141 NotOwnEvent,
142 #[error("event to edit not found")]
143 MissingEvent,
144}
145
146#[derive(Debug, Error)]
147pub enum SendEventError {
148 #[error(transparent)]
149 UnsupportedEditItem(#[from] UnsupportedEditItem),
150
151 #[error(transparent)]
152 RoomQueueError(#[from] RoomSendQueueError),
153}