use thiserror::Error;
pub type Result<T> = std::result::Result<T, WitherError>;
#[derive(Debug, Error)]
pub enum WitherError {
#[error("{0}")]
Mongo(#[from] mongodb::error::Error),
#[error("{0}")]
BsonOid(#[from] mongodb::bson::oid::Error),
#[error("{0}")]
BsonDe(#[from] mongodb::bson::de::Error),
#[error("{0}")]
BsonSer(#[from] mongodb::bson::ser::Error),
#[error("Model must have an ObjectId for this operation.")]
ModelIdRequiredForOperation,
#[error("Serializing model to BSON failed to produce a Bson::Document, got type {0:?}")]
ModelSerToDocument(mongodb::bson::spec::ElementType),
#[error("Server failed to return the updated document. Update may have failed.")]
ServerFailedToReturnUpdatedDoc,
#[error("Server failed to return ObjectId of updated document.")]
ServerFailedToReturnObjectId,
#[error("One of '$set' or '$unset' must be specified.")]
MigrationSetOrUnsetRequired,
}