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("The Event Cache must be enabled to use the Timeline.")]
65 EventCacheIsDisabled,
66
67 #[error(transparent)]
69 EventCacheError(#[from] EventCacheError),
70
71 #[error(transparent)]
73 PaginationError(#[from] PaginationError),
74
75 #[error(transparent)]
77 SendQueueError(#[from] RoomSendQueueError),
78
79 #[error(transparent)]
81 EditError(#[from] EditError),
82
83 #[error(transparent)]
85 ReplyError(#[from] ReplyError),
86
87 #[error(transparent)]
89 RedactError(#[from] RedactError),
90}
91
92#[derive(Error, Debug)]
93pub enum EditError {
94 #[error("the new content type ({new}) doesn't match that of the previous content ({original}")]
96 ContentMismatch { original: String, new: String },
97
98 #[error("Invalid state: the local echo we tried to abort has been lost.")]
100 InvalidLocalEchoState,
101
102 #[error(transparent)]
104 RoomError(#[from] matrix_sdk::room::edit::EditError),
105}
106
107#[derive(Error, Debug)]
108pub enum RedactError {
109 #[error("Event to redact wasn't found for item id {0:?}")]
111 ItemNotFound(TimelineEventItemId),
112
113 #[error(transparent)]
115 HttpError(#[from] HttpError),
116
117 #[error("Invalid state: the local echo we tried to abort has been lost.")]
119 InvalidLocalEchoState,
120}
121
122#[derive(Error, Debug)]
123pub enum PaginationError {
124 #[error("Error when paginating: {0}")]
126 Pagination(#[from] PaginatorError),
127
128 #[error("Error in event cache.")]
130 EventCache(#[source] EventCacheError),
131
132 #[error("Missing cache for focused event")]
134 MissingCache,
135
136 #[error("Pagination type not supported in this focus mode")]
137 NotSupported,
138}
139
140#[derive(Debug, Error)]
141pub enum UnsupportedEditItem {
142 #[error("tried to edit a non-poll event")]
143 NotPollEvent,
144 #[error("tried to edit another user's event")]
145 NotOwnEvent,
146 #[error("event to edit not found")]
147 MissingEvent,
148}
149
150#[derive(Debug, Error)]
151pub enum SendEventError {
152 #[error(transparent)]
153 UnsupportedEditItem(#[from] UnsupportedEditItem),
154
155 #[error(transparent)]
156 RoomQueueError(#[from] RoomSendQueueError),
157}