client: add error type field for --json outputs
Some checks failed
Some checks failed
This commit is contained in:
@@ -44,6 +44,7 @@ pub fn print_create_databases_output_status_json(output: &CreateDatabasesRespons
|
||||
name.to_string(),
|
||||
json!({
|
||||
"status": "error",
|
||||
"type": err.error_type(),
|
||||
"error": err.to_error_message(name),
|
||||
}),
|
||||
),
|
||||
@@ -73,4 +74,13 @@ impl CreateDatabaseError {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error_type(&self) -> &'static str {
|
||||
match self {
|
||||
CreateDatabaseError::SanitizationError(_) => "sanitization-error",
|
||||
CreateDatabaseError::OwnershipError(_) => "ownership-error",
|
||||
CreateDatabaseError::DatabaseAlreadyExists => "database-already-exists",
|
||||
CreateDatabaseError::MySqlError(_) => "mysql-error",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user