Skip to main content

DatasetError

Enum DatasetError 

Source
pub enum DatasetError {
    DownloadError(Error),
    ValidationError(String),
    UnzipError(ZipError),
    IoError(Error),
    DataFormatError(DataFormatErrorKind),
}
Expand description

Error type used by dataset loading utilities.

§Variants

  • DownloadError - The download step failed (network, invalid URL, or downloader configuration).
  • ValidationError - Downloaded file content failed integrity validation (SHA256 mismatch).
  • UnzipError - Extracting a zip archive failed.
  • IoError - A standard I/O operation failed (reading directories, opening/removing files, etc.).
  • DataFormatError - The dataset content was not in the expected format.

Variants§

§

DownloadError(Error)

§

ValidationError(String)

§

UnzipError(ZipError)

§

IoError(Error)

§

DataFormatError(DataFormatErrorKind)

Implementations§

Source§

impl DatasetError

Source

pub fn sha256_validation_failed(dataset_name: &str, file_name: &str) -> Self

Creates a standard SHA256 validation failure error message for a file.

§Parameters
  • dataset_name - The dataset identifier used in the error prefix.
  • file_name - The dataset file name that failed checksum validation.
§Returns
  • DatasetError::ValidationError - A variant of DatasetError that contains the unified SHA256 failure message.
Source

pub fn csv_read_error(dataset_name: &str, error: impl Display) -> Self

Creates a CSV read error.

§Parameters
  • dataset_name - The dataset identifier.
  • error - The underlying CSV error.
§Returns
  • DatasetError::DataFormatError(DataFormatErrorKind::CsvReadError) - A variant of DatasetError describing the CSV read error.
Source

pub fn invalid_column_count( dataset_name: &str, expected: usize, actual: usize, line_num: usize, line: &str, ) -> Self

Creates a unified invalid-column-count data format error.

§Parameters
  • dataset_name - The dataset identifier used in the error prefix.
  • expected - The expected number of columns.
  • actual - The actual number of columns found.
  • line_num - The line number (1-based) where the error occurred.
  • line - The original input line that failed validation.
§Returns
  • DatasetError::DataFormatError(DataFormatErrorKind::InvalidColumnCount) - A variant of DatasetError describing the column count mismatch.
Source

pub fn parse_failed( dataset_name: &str, field_name: &str, line_num: usize, line: &str, err: impl Display, ) -> Self

Creates a unified parse failure data format error.

§Parameters
  • dataset_name - The dataset identifier.
  • field_name - The logical field name that failed to parse.
  • line_num - The line number (1-based) where the error occurred.
  • line - The original input line where parsing failed.
  • err - The underlying parser error detail.
§Returns
  • DatasetError::DataFormatError(DataFormatErrorKind::ParseFailed) - A variant of DatasetError describing the parse failure.
Source

pub fn invalid_value( dataset_name: &str, field_name: &str, value: &str, line_num: usize, line: &str, ) -> Self

Creates a unified invalid-field-value data format error.

§Parameters
  • dataset_name - The dataset identifier.
  • field_name - The logical field name with an invalid value.
  • value - The invalid raw value.
  • line_num - The line number (1-based) where the error occurred.
  • line - The original input line where the invalid value was found.
§Returns
  • DatasetError::DataFormatError(DataFormatErrorKind::InvalidValue) - A variant of DatasetError describing the invalid value.
Source

pub fn length_mismatch( dataset_name: &str, field_name: &str, expected: usize, actual: usize, ) -> Self

Creates a unified vector/row length mismatch data format error.

§Parameters
  • dataset_name - The dataset identifier.
  • field_name - The logical field name whose length is being validated.
  • expected - The expected length.
  • actual - The actual length.
§Returns
  • DatasetError::DataFormatError(DataFormatErrorKind::LengthMismatch) - A variant of DatasetError describing the length mismatch.
Source

pub fn array_shape_error( dataset_name: &str, array_name: &str, err: impl Display, ) -> Self

Creates a unified ndarray shape construction data format error.

§Parameters
  • dataset_name - The dataset identifier.
  • array_name - The logical array name that failed to build.
  • err - The underlying ndarray shape construction error detail.
§Returns
  • DatasetError::DataFormatError(DataFormatErrorKind::ArrayShapeError) - A variant of DatasetError describing the array shape failure.
Source

pub fn empty_dataset(dataset_name: &str) -> Self

Creates an empty dataset error.

§Parameters
  • dataset_name - The dataset identifier.
§Returns
  • DatasetError::DataFormatError(DataFormatErrorKind::EmptyDataset) - A variant of DatasetError indicating the dataset is empty.

Trait Implementations§

Source§

impl Debug for DatasetError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DatasetError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for DatasetError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<DataFormatErrorKind> for DatasetError

Source§

fn from(source: DataFormatErrorKind) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for DatasetError

Source§

fn from(source: UreqError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for DatasetError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<ZipError> for DatasetError

Source§

fn from(source: ZipError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.