pub const COLUMN_NOT_FOUND: &str =
"This may indicate a mismatch between the query and expected result structure.";
pub const ROW_NOT_FOUND: &str = "Verify the identifier and try again.";
pub const UNIQUE_VIOLATION: &str = "Please use a different value or update the existing record.";
pub const FOREIGN_KEY_VIOLATION: &str = "Ensure all referenced resources exist and are accessible.";
pub const NOT_NULL_VIOLATION: &str = "Please provide all required fields.";
pub const CHECK_CONSTRAINT_VIOLATION: &str =
"Please ensure the value meets all validation requirements.";
pub const INVALID_TEXT_ENCODING: &str =
"Remove unsupported characters and ensure text is valid UTF-8.";
pub const UNDEFINED_COLUMN: &str = "Please verify the column name and try again.";
pub const UNDEFINED_TABLE_WITH_NAME: &str = "It may not exist yet, or you might have a typo. Check your migrations or ensure you're connected to the correct schema.";
pub const UNDEFINED_TABLE_GENERIC: &str =
"Please verify the table name and ensure it has been created.";
pub const SYNTAX_ERROR: &str = "Please check your query syntax.";
pub const INSUFFICIENT_PRIVILEGE: &str = "Please contact an administrator for access.";
pub const CONNECTION_ERROR: &str = "The database is temporarily unavailable. Please try again.";
pub const INTERNAL_ERROR: &str =
"An unexpected error occurred. Please contact support if this persists.";
pub const POOL_TIMEOUT: &str =
"The system is experiencing high load. Please try again in a moment.";
pub const POOL_CLOSED: &str =
"The database connection pool has been shut down. Please contact support.";
pub fn undefined_table(table_name: Option<&str>) -> (String, &'static str) {
match table_name {
Some(t) => (
format!("The table '{}' was not found.", t),
UNDEFINED_TABLE_WITH_NAME,
),
None => (
"The specified table does not exist".to_string(),
UNDEFINED_TABLE_GENERIC,
),
}
}