pub fn classify_error(err: &Error) -> CliExitCodeExpand description
Classify an error into appropriate exit code category
Examines the error message and context chain to determine the most appropriate exit code per M2_CLI_SPEC.md exit code policy.
Classification logic (order matters - most specific first):
- CLI argument parsing errors -> InvalidCliArgs (2)
- Schema-related errors -> SchemaError (3)
- Data directory/SSTable errors -> DataDirError (4)
- Default: Query execution errors -> QueryExecutionError (5)
§Examples
use anyhow::anyhow;
use cqlite_cli::error::{classify_error, CliExitCode};
let err = anyhow!("Failed to parse schema file");
assert_eq!(classify_error(&err), CliExitCode::SchemaError);
let err = anyhow!("Data directory not found");
assert_eq!(classify_error(&err), CliExitCode::DataDirError);