use hecs::{ComponentError, NoSuchEntity};
use persy::{
BeginTransactionError, CreateIndexError, GenericError, IndexPutError, OpenError, PE,
PrepareError,
};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum QmiError {
#[error("Failed to open or create database: {0}")]
Database(#[from] PE<OpenError>),
#[error("Entity does not exist: {0}")]
NoSuchEntity(#[from] NoSuchEntity),
#[error("Component invalid: {0}")]
ComponentError(#[from] ComponentError),
#[error("Could not begin transaction: {0}")]
DbTransactionError(#[from] PE<BeginTransactionError>),
#[error("Could not create index: {0}")]
DbCreateIndexError(#[from] PE<CreateIndexError>),
#[error("Expected index does not exist")]
DbNoSuchIndex,
#[error("Could not prepare transaction: {0}")]
DbPrepareTxError(#[from] PE<PrepareError>),
#[error("Could not insert into index: {0}")]
DbIndexPutError(#[from] PE<IndexPutError>),
#[error("Something went wrong with the database: {0}")]
DbGenericError(#[from] PE<GenericError>),
#[error("Serialization/Deserialization failed: {0}")]
Postcard(#[from] postcard::Error),
#[error("Component could not be saved")]
ComponentSave,
}