use tonic::Status;
pub fn hermes_error_to_status(e: hermes_core::Error) -> Status {
match &e {
hermes_core::Error::Schema(_) => Status::invalid_argument(e.to_string()),
hermes_core::Error::Query(_) => Status::invalid_argument(e.to_string()),
hermes_core::Error::Document(_) => Status::invalid_argument(e.to_string()),
hermes_core::Error::Tokenizer(_) => Status::invalid_argument(e.to_string()),
hermes_core::Error::InvalidFieldType { .. } => Status::invalid_argument(e.to_string()),
hermes_core::Error::FieldNotFound(_) => Status::not_found(e.to_string()),
hermes_core::Error::DocumentNotFound(_) => Status::not_found(e.to_string()),
hermes_core::Error::DuplicatePrimaryKey(_) => Status::already_exists(e.to_string()),
hermes_core::Error::QueueFull => Status::resource_exhausted(e.to_string()),
hermes_core::Error::IndexClosed => Status::failed_precondition(e.to_string()),
hermes_core::Error::Io(_) => Status::unavailable(e.to_string()),
hermes_core::Error::Corruption(_) => Status::internal(e.to_string()),
hermes_core::Error::Serialization(_) => Status::internal(e.to_string()),
hermes_core::Error::Internal(_) => Status::internal(e.to_string()),
}
}