use matrix_sdk::{
event_cache::{paginator::PaginatorError, EventCacheError},
room::edit::EditError,
send_queue::RoomSendQueueError,
HttpError,
};
use thiserror::Error;
use crate::timeline::pinned_events_loader::PinnedEventsLoaderError;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("Event with remote echo not found in timeline")]
RemoteEventNotInTimeline,
#[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("Something went wrong with the room event cache.")]
EventCacheError(#[from] EventCacheError),
#[error("An error happened during pagination.")]
PaginationError(#[from] PaginationError),
#[error("An error happened when loading pinned events.")]
PinnedEventsError(#[from] PinnedEventsLoaderError),
#[error(transparent)]
SendQueueError(#[from] RoomSendQueueError),
#[error(transparent)]
EditError(#[from] EditError),
#[error(transparent)]
RedactError(HttpError),
}
#[derive(Error, Debug)]
pub enum PaginationError {
#[error("The timeline isn't in the event focus mode")]
NotEventFocusMode,
#[error("Error when paginating.")]
Paginator(#[source] PaginatorError),
}
#[derive(Debug, Error)]
pub enum UnsupportedReplyItem {
#[error("local messages whose event ID is not known can't be replied to currently")]
MissingEventId,
#[error("redacted events whose JSON form isn't available can't be replied")]
MissingJson,
#[error("event to reply to not found")]
MissingEvent,
#[error("failed to deserialize event to reply to")]
FailedToDeserializeEvent,
#[error("tried to reply to a state event")]
StateEvent,
}
#[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),
}