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: {0}")]
114 Pagination(#[from] PaginatorError),
115
116 #[error("Error in event cache.")]
118 EventCache(#[source] EventCacheError),
119
120 #[error("Missing cache for focused event")]
122 MissingCache,
123
124 #[error("Pagination type not supported in this focus mode")]
125 NotSupported,
126}
127
128#[derive(Debug, Error)]
129pub enum UnsupportedEditItem {
130 #[error("tried to edit a non-poll event")]
131 NotPollEvent,
132 #[error("tried to edit another user's event")]
133 NotOwnEvent,
134 #[error("event to edit not found")]
135 MissingEvent,
136}
137
138#[derive(Debug, Error)]
139pub enum SendEventError {
140 #[error(transparent)]
141 UnsupportedEditItem(#[from] UnsupportedEditItem),
142
143 #[error(transparent)]
144 RoomQueueError(#[from] RoomSendQueueError),
145}