use matrix_sdk::{
HttpError, event_cache::EventCacheError, paginators::PaginatorError, room::reply::ReplyError,
send_queue::RoomSendQueueError,
};
use thiserror::Error;
use crate::timeline::TimelineEventItemId;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("Event not found in timeline: {0:?}")]
EventNotInTimeline(TimelineEventItemId),
#[error("Unsupported event")]
UnsupportedEvent,
#[error("Invalid attachment data")]
InvalidAttachmentData,
#[error("Invalid attachment file name")]
InvalidAttachmentFileName,
#[error("Failed sending attachment")]
FailedSendingAttachment,
#[error("Failed toggling reaction")]
FailedToToggleReaction,
#[error("The room's encryption state is unknown.")]
UnknownEncryptionState,
#[error(transparent)]
EventCacheError(#[from] EventCacheError),
#[error(transparent)]
PaginationError(#[from] PaginationError),
#[error(transparent)]
SendQueueError(#[from] RoomSendQueueError),
#[error(transparent)]
EditError(#[from] EditError),
#[error(transparent)]
ReplyError(#[from] ReplyError),
#[error(transparent)]
RedactError(#[from] RedactError),
}
#[derive(Error, Debug)]
pub enum EditError {
#[error("the new content type ({new}) doesn't match that of the previous content ({original}")]
ContentMismatch { original: String, new: String },
#[error("Invalid state: the local echo we tried to abort has been lost.")]
InvalidLocalEchoState,
#[error(transparent)]
RoomError(#[from] matrix_sdk::room::edit::EditError),
}
#[derive(Error, Debug)]
pub enum RedactError {
#[error("Event to redact wasn't found for item id {0:?}")]
ItemNotFound(TimelineEventItemId),
#[error(transparent)]
HttpError(#[from] HttpError),
#[error("Invalid state: the local echo we tried to abort has been lost.")]
InvalidLocalEchoState,
}
#[derive(Error, Debug)]
pub enum PaginationError {
#[error("Error when paginating: {0}")]
Pagination(#[from] PaginatorError),
#[error("Error in event cache.")]
EventCache(#[source] EventCacheError),
#[error("Missing cache for focused event")]
MissingCache,
#[error("Pagination type not supported in this focus mode")]
NotSupported,
}
#[derive(Debug, Error)]
pub enum UnsupportedEditItem {
#[error("tried to edit a non-poll event")]
NotPollEvent,
#[error("tried to edit another user's event")]
NotOwnEvent,
#[error("event to edit not found")]
MissingEvent,
}
#[derive(Debug, Error)]
pub enum SendEventError {
#[error(transparent)]
UnsupportedEditItem(#[from] UnsupportedEditItem),
#[error(transparent)]
RoomQueueError(#[from] RoomSendQueueError),
}