///|
/// Formats a concise explanation suitable for logs and command-line output.
pub fn error_message(error : SvmError) -> String {
  match error {
    EmptyDataset => "the dataset contains no rows"
    EmptyFeatureSet => "the dataset contains no feature columns"
    RaggedRow(row, expected, actual) =>
      "row \{row} has \{actual} features; expected \{expected}"
    LabelLengthMismatch(rows, labels) =>
      "dataset row count \{rows} differs from label count \{labels}"
    NonFiniteFeature(row, column) =>
      "feature at row \{row}, column \{column} is not finite"
    SingleClassDataset => "training requires at least two distinct classes"
    InvalidSubsetIndex(index, rows) =>
      "subset index \{index} is outside dataset length \{rows}"
    DuplicateSubsetIndex(index) => "subset index \{index} occurs more than once"
    InvalidKernelParameter(name, value) =>
      "kernel parameter \{name} is invalid: \{value}"
    KernelDimensionMismatch(left, right) =>
      "kernel vectors differ in length: \{left} and \{right}"
    InvalidConfiguration(name, value) =>
      "configuration value \{name} is invalid: \{value}"
    InvalidIterationCount(value) =>
      "maximum iterations must be positive, received \{value}"
    InvalidWeight(index, value) =>
      "sample weight at index \{index} is invalid: \{value}"
    WeightLengthMismatch(rows, weights) =>
      "dataset row count \{rows} differs from weight count \{weights}"
    InvalidClassWeight(label, value) =>
      "weight for class \{label} is invalid: \{value}"
    DuplicateClassWeight(label) =>
      "class weight for label \{label} occurs more than once"
    ZeroEffectiveWeight =>
      "at least one class has zero effective training weight"
    InvalidBinaryClassCount(count) =>
      "binary training requires exactly two classes, received \{count}"
    PredictionDimensionMismatch(expected, actual) =>
      "prediction vector has \{actual} features; expected \{expected}"
    TrainingDidNotConverge(iterations) =>
      "training did not converge within \{iterations} iterations"
    NumericFailure(operation) =>
      "a nonfinite numeric result occurred during \{operation}"
    InvalidFoldCount(count) =>
      "fold count must be at least two, received \{count}"
    InsufficientClassSamples(label, count, folds) =>
      "class \{label} has \{count} samples, fewer than \{folds} folds"
    EmptyMetricInput =>
      "classification metrics require at least one observation"
    MetricLengthMismatch(actual, predicted) =>
      "actual label count \{actual} differs from prediction count \{predicted}"
    UnknownClassLabel(label) =>
      "label \{label} is absent from the declared class order"
    InvalidCandidateCount(count) =>
      "candidate count must be positive, received \{count}"
    NoValidCandidate => "all SVM candidates failed validation or fitting"
    NonFiniteReportValue(field) =>
      "report field \{field} contains a nonfinite value"
  }
}