cli: avoid data-dir initialization for version; create db parent dirs; redact generated passwords in CLI output
- Prevent 'nx9-wg version' from creating data directories by avoiding database initialization. - Create parent directories when an explicit --database path is provided. - Redact printed generated administrator passwords; announce file path or redact instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
commit
2ac6c81dfe
140 files changed
+31342
No files matched your search
@@ -0,0 +1,44 @@
|
||||
//! Database error types.
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
/// Result type for database operations.
|
||||
pub type Result<T> = std::result::Result<T, DbError>;
|
||||
|
||||
/// Database-specific errors.
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DbError {
|
||||
/// Entity was not found.
|
||||
#[error("entity not found: {0}")]
|
||||
NotFound(String),
|
||||
|
||||
/// Unique or foreign key constraint violation.
|
||||
#[error("constraint violation: {0}")]
|
||||
ConstraintViolation(String),
|
||||
|
||||
/// Conflict, e.g. entity already exists.
|
||||
#[error("conflict: {0}")]
|
||||
Conflict(String),
|
||||
|
||||
/// Validation error when converting from raw database values.
|
||||
#[error("validation error: {0}")]
|
||||
Validation(String),
|
||||
|
||||
/// SQLx database error.
|
||||
#[error("database error: {0}")]
|
||||
Sqlx(#[from] sqlx::Error),
|
||||
|
||||
/// Migration failure.
|
||||
#[error("migration error: {0}")]
|
||||
Migration(String),
|
||||
|
||||
/// Internal or unexpected error.
|
||||
#[error("internal database error: {0}")]
|
||||
Internal(String),
|
||||
}
|
||||
|
||||
impl From<nx9_wg_core::error::Nx9Error> for DbError {
|
||||
fn from(err: nx9_wg_core::error::Nx9Error) -> Self {
|
||||
Self::Validation(err.to_string())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user