matrix_sdk_ui/timeline/
error.rs1use matrix_sdk::{
16 event_cache::EventCacheError, paginators::PaginatorError, room::reply::ReplyError,
17 send_queue::RoomSendQueueError, HttpError,
18};
19use thiserror::Error;
20
21use crate::timeline::{pinned_events_loader::PinnedEventsLoaderError, 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 PinnedEventsError(#[from] PinnedEventsLoaderError),
66
67 #[error(transparent)]
69 SendQueueError(#[from] RoomSendQueueError),
70
71 #[error(transparent)]
73 EditError(#[from] EditError),
74
75 #[error(transparent)]
77 ReplyError(#[from] ReplyError),
78
79 #[error(transparent)]
81 RedactError(#[from] RedactError),
82}
83
84#[derive(Error, Debug)]
85pub enum EditError {
86 #[error("the new content type ({new}) doesn't match that of the previous content ({original}")]
88 ContentMismatch { original: String, new: String },
89
90 #[error("Invalid state: the local echo we tried to abort has been lost.")]
92 InvalidLocalEchoState,
93
94 #[error(transparent)]
96 RoomError(#[from] matrix_sdk::room::edit::EditError),
97}
98
99#[derive(Error, Debug)]
100pub enum RedactError {
101 #[error("Event to redact wasn't found for item id {0:?}")]
103 ItemNotFound(TimelineEventItemId),
104
105 #[error(transparent)]
107 HttpError(#[from] HttpError),
108
109 #[error("Invalid state: the local echo we tried to abort has been lost.")]
111 InvalidLocalEchoState,
112}
113
114#[derive(Error, Debug)]
115pub enum PaginationError {
116 #[error("Error when paginating.")]
118 Paginator(#[source] PaginatorError),
119
120 #[error("Pagination type not supported in this focus mode")]
121 NotSupported,
122}
123
124#[derive(Debug, Error)]
125pub enum UnsupportedEditItem {
126 #[error("tried to edit a non-poll event")]
127 NotPollEvent,
128 #[error("tried to edit another user's event")]
129 NotOwnEvent,
130 #[error("event to edit not found")]
131 MissingEvent,
132}
133
134#[derive(Debug, Error)]
135pub enum SendEventError {
136 #[error(transparent)]
137 UnsupportedEditItem(#[from] UnsupportedEditItem),
138
139 #[error(transparent)]
140 RoomQueueError(#[from] RoomSendQueueError),
141}