in safetensors/src/tensor.rs [68:95]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
use SafeTensorError::*;
match self {
InvalidHeader(error) => write!(f, "invalid UTF-8 in header: {error}"),
InvalidHeaderStart => write!(f, "invalid start character in header, must be `{{`"),
InvalidHeaderDeserialization(error) => write!(f, "invalid JSON in header: {error}"),
JsonError(error) => write!(f, "JSON error: {error}"),
HeaderTooLarge => write!(f, "header too large"),
HeaderTooSmall => write!(f, "header too small"),
InvalidHeaderLength => write!(f, "invalid header length"),
TensorNotFound(name) => write!(f, "tensor `{name}` not found"),
TensorInvalidInfo => write!(f, "invalid shape, data type, or offset for tensor"),
InvalidOffset(name) => write!(f, "invalid offset for tensor `{name}`"),
#[cfg(feature = "std")]
IoError(error) => write!(f, "I/O error: {error}"),
InvalidTensorView(dtype, shape, n_bytes) => {
write!(f, "tensor of type {dtype} and shape (")?;
for (i, &dim) in shape.iter().enumerate() {
write!(f, "{sep}{dim}", sep = if i == 0 { "" } else { ", " })?;
}
write!(f, ") can't be created from {n_bytes} bytes")
}
MetadataIncompleteBuffer => write!(f, "incomplete metadata, file not fully covered"),
ValidationOverflow => write!(f, "overflow computing buffer size from shape and/or element type"),
MisalignedSlice => write!(f, "The slice is slicing for subbytes dtypes, and the slice does not end up at a byte boundary, this is invalid.")
}
}