use crate::error::InternalError;
pub(in crate::db) struct IndexPlanError {
error: InternalError,
unique_violation_entity_path: Option<&'static str>,
}
impl IndexPlanError {
#[must_use]
pub(in crate::db) const fn new(error: InternalError) -> Self {
Self {
error,
unique_violation_entity_path: None,
}
}
#[must_use]
pub(in crate::db) fn unique_violation(
entity_path: &'static str,
index_fields: &[&str],
) -> Self {
Self {
error: InternalError::index_violation(entity_path, index_fields),
unique_violation_entity_path: Some(entity_path),
}
}
#[must_use]
pub(in crate::db) const fn unique_violation_entity_path(&self) -> Option<&'static str> {
self.unique_violation_entity_path
}
#[must_use]
pub(in crate::db) fn into_internal_error(self) -> InternalError {
self.error
}
}
impl From<InternalError> for IndexPlanError {
fn from(error: InternalError) -> Self {
Self::new(error)
}
}