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 sending redaction")]
49 FailedSendingRedaction,
50
51 #[error("Failed toggling reaction")]
53 FailedToToggleReaction,
54
55 #[error("The room's encryption state is unknown.")]
57 UnknownEncryptionState,
58
59 #[error(transparent)]
61 Sdk(#[from] matrix_sdk::Error),
62
63 #[error(transparent)]
65 EventCacheError(#[from] EventCacheError),
66
67 #[error(transparent)]
69 PaginationError(#[from] PaginationError),
70
71 #[error(transparent)]
73 SendQueueError(#[from] RoomSendQueueError),
74
75 #[error(transparent)]
77 EditError(#[from] EditError),
78
79 #[error(transparent)]
81 ReplyError(#[from] ReplyError),
82
83 #[error(transparent)]
85 RedactError(#[from] RedactError),
86}
87
88#[derive(Error, Debug)]
89pub enum EditError {
90 #[error("the new content type ({new}) doesn't match that of the previous content ({original}")]
92 ContentMismatch { original: String, new: String },
93
94 #[error("Invalid state: the local echo we tried to abort has been lost.")]
96 InvalidLocalEchoState,
97
98 #[error(transparent)]
100 RoomError(#[from] matrix_sdk::room::edit::EditError),
101}
102
103#[derive(Error, Debug)]
104pub enum RedactError {
105 #[error("Event to redact wasn't found for item id {0:?}")]
107 ItemNotFound(TimelineEventItemId),
108
109 #[error(transparent)]
111 HttpError(#[from] HttpError),
112
113 #[error("Invalid state: the local echo we tried to abort has been lost.")]
115 InvalidLocalEchoState,
116}
117
118#[derive(Error, Debug)]
119pub enum PaginationError {
120 #[error("Error when paginating: {0}")]
122 Pagination(#[from] PaginatorError),
123
124 #[error("Error in event cache.")]
126 EventCache(#[source] EventCacheError),
127
128 #[error("Missing cache for focused event")]
130 MissingCache,
131
132 #[error("Pagination type not supported in this focus mode")]
133 NotSupported,
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}