use thiserror::Error;

#[derive(Debug, Error)]
pub enum MatrixError {
    #[error("Matrix SDK error: {0}")]
    Sdk(#[from] matrix_sdk::Error),

    #[error("Matrix HTTP error: {0}")]
    Http(#[from] matrix_sdk::HttpError),

    #[error("Matrix client build error: {0}")]
    ClientBuild(#[from] matrix_sdk::ClientBuildError),

    #[error("Not logged in")]
    NotLoggedIn,

    #[error("Room not found: {0}")]
    RoomNotFound(String),

    #[error("Share not found: connector={connector_id} session={session_id}")]
    ShareNotFound {
        connector_id: String,
        session_id: String,
    },

    #[error("Share already exists: connector={connector_id} session={session_id}")]
    ShareAlreadyExists {
        connector_id: String,
        session_id: String,
    },

    #[error("Configuration error: {0}")]
    Config(String),

    #[error("Channel closed")]
    ChannelClosed,
}

pub type Result<T> = std::result::Result<T, MatrixError>;
