Error handling

Updated Oct 20, 2025

Builder validation returns ChutoroError::InvalidMinClusterSize when the provided minimum cluster size is zero. Chutoro::run surfaces runtime failures via ChutoroError variants:

  • EmptySource: returned when a DataSource yields zero items.
  • InsufficientItems: triggered if len() falls below min_cluster_size.
  • BackendUnavailable: emitted when the requested ExecutionStrategy is not compiled into the binary.
  • DataSource: raised when distance or distance_batch fails. Use ChutoroError::data_source_code() to recover the underlying DataSourceErrorCode and respond programmatically.

DataSourceError distinguishes out-of-bounds indices, dimension mismatches, and invalid buffers. Propagate these errors verbatim, so callers receive stable error codes via DataSourceError::code().