pub enum TorshError {
Show 28 variants
Shape(ShapeError),
Index(IndexError),
General(GeneralError),
WithContext {
message: String,
error_category: ErrorCategory,
severity: ErrorSeverity,
debug_context: Box<ErrorDebugContext>,
source: Option<Box<TorshError>>,
},
ShapeMismatch {
expected: Vec<usize>,
got: Vec<usize>,
},
BroadcastError {
shape1: Vec<usize>,
shape2: Vec<usize>,
},
IndexOutOfBounds {
index: usize,
size: usize,
},
InvalidArgument(String),
IoError(String),
DeviceMismatch,
NotImplemented(String),
SynchronizationError(String),
AllocationError(String),
InvalidOperation(String),
ConversionError(String),
BackendError(String),
InvalidShape(String),
RuntimeError(String),
DeviceError(String),
ConfigError(String),
InvalidState(String),
UnsupportedOperation {
op: String,
dtype: String,
},
AutogradError(String),
ComputeError(String),
SerializationError(String),
IndexError {
index: usize,
size: usize,
},
IterationError(String),
Other(String),
}Expand description
Main ToRSh error enum - unified interface to all error types
Variants§
Shape(ShapeError)
Index(IndexError)
General(GeneralError)
WithContext
Fields
error_category: ErrorCategoryseverity: ErrorSeveritydebug_context: Box<ErrorDebugContext>source: Option<Box<TorshError>>ShapeMismatch
BroadcastError
IndexOutOfBounds
InvalidArgument(String)
IoError(String)
DeviceMismatch
NotImplemented(String)
SynchronizationError(String)
AllocationError(String)
InvalidOperation(String)
ConversionError(String)
BackendError(String)
InvalidShape(String)
RuntimeError(String)
DeviceError(String)
ConfigError(String)
InvalidState(String)
UnsupportedOperation
AutogradError(String)
ComputeError(String)
SerializationError(String)
IndexError
IterationError(String)
Other(String)
Implementations§
Source§impl TorshError
impl TorshError
Sourcepub fn shape_mismatch(expected: &[usize], got: &[usize]) -> TorshError
pub fn shape_mismatch(expected: &[usize], got: &[usize]) -> TorshError
Create a shape mismatch error (backward compatibility)
Sourcepub fn dimension_error(msg: &str, operation: &str) -> TorshError
pub fn dimension_error(msg: &str, operation: &str) -> TorshError
Create a dimension error during operation
Sourcepub fn index_error(index: usize, size: usize) -> TorshError
pub fn index_error(index: usize, size: usize) -> TorshError
Create an index error
Sourcepub fn type_mismatch(expected: &str, actual: &str) -> TorshError
pub fn type_mismatch(expected: &str, actual: &str) -> TorshError
Create a type mismatch error
Sourcepub fn dimension_error_with_context(msg: &str, operation: &str) -> TorshError
pub fn dimension_error_with_context(msg: &str, operation: &str) -> TorshError
Create a dimension error with context (backward compatibility)
Sourcepub fn synchronization_error(msg: &str) -> TorshError
pub fn synchronization_error(msg: &str) -> TorshError
Create a synchronization error (backward compatibility)
Sourcepub fn allocation_error(msg: &str) -> TorshError
pub fn allocation_error(msg: &str) -> TorshError
Create an allocation error (backward compatibility)
Sourcepub fn invalid_operation(msg: &str) -> TorshError
pub fn invalid_operation(msg: &str) -> TorshError
Create an invalid operation error (backward compatibility)
Sourcepub fn conversion_error(msg: &str) -> TorshError
pub fn conversion_error(msg: &str) -> TorshError
Create a conversion error (backward compatibility)
Sourcepub fn invalid_argument_with_context(msg: &str, context: &str) -> TorshError
pub fn invalid_argument_with_context(msg: &str, context: &str) -> TorshError
Create an invalid argument error with context (backward compatibility)
Sourcepub fn config_error_with_context(msg: &str, context: &str) -> TorshError
pub fn config_error_with_context(msg: &str, context: &str) -> TorshError
Create a config error with context (backward compatibility)
Sourcepub fn dimension_error_simple(msg: String) -> TorshError
pub fn dimension_error_simple(msg: String) -> TorshError
Create a dimension error (backward compatibility)
Sourcepub fn shape_mismatch_formatted(expected: &str, got: &str) -> TorshError
pub fn shape_mismatch_formatted(expected: &str, got: &str) -> TorshError
Create a formatted shape mismatch error (backward compatibility)
Sourcepub fn operation_error(msg: &str) -> TorshError
pub fn operation_error(msg: &str) -> TorshError
Create an operation error (backward compatibility)
Sourcepub fn wrap_with_location(self, location: String) -> TorshError
pub fn wrap_with_location(self, location: String) -> TorshError
Wrap an error with location information (backward compatibility)
Sourcepub fn category(&self) -> ErrorCategory
pub fn category(&self) -> ErrorCategory
Get the error category
Sourcepub fn severity(&self) -> ErrorSeverity
pub fn severity(&self) -> ErrorSeverity
Get the error severity
Sourcepub fn with_context(self, message: &str) -> TorshError
pub fn with_context(self, message: &str) -> TorshError
Add context to an error
Trait Implementations§
Source§impl Clone for TorshError
impl Clone for TorshError
Source§fn clone(&self) -> TorshError
fn clone(&self) -> TorshError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TorshError
impl Debug for TorshError
Source§impl Display for TorshError
impl Display for TorshError
Source§impl Error for TorshError
impl Error for TorshError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<Error> for TorshError
impl From<Error> for TorshError
Source§fn from(err: Error) -> TorshError
fn from(err: Error) -> TorshError
Source§impl From<Error> for TorshError
impl From<Error> for TorshError
Source§fn from(err: Error) -> TorshError
fn from(err: Error) -> TorshError
Source§impl From<GeneralError> for TorshError
impl From<GeneralError> for TorshError
Source§fn from(source: GeneralError) -> TorshError
fn from(source: GeneralError) -> TorshError
Source§impl From<IndexError> for TorshError
impl From<IndexError> for TorshError
Source§fn from(source: IndexError) -> TorshError
fn from(source: IndexError) -> TorshError
Source§impl From<ParseFloatError> for TorshError
impl From<ParseFloatError> for TorshError
Source§fn from(err: ParseFloatError) -> TorshError
fn from(err: ParseFloatError) -> TorshError
Source§impl From<ParseIntError> for TorshError
impl From<ParseIntError> for TorshError
Source§fn from(err: ParseIntError) -> TorshError
fn from(err: ParseIntError) -> TorshError
Source§impl<T> From<PoisonError<T>> for TorshError
impl<T> From<PoisonError<T>> for TorshError
Source§fn from(err: PoisonError<T>) -> TorshError
fn from(err: PoisonError<T>) -> TorshError
Source§impl From<ShapeError> for TorshError
impl From<ShapeError> for TorshError
Source§fn from(source: ShapeError) -> TorshError
fn from(source: ShapeError) -> TorshError
Source§impl From<TryFromIntError> for TorshError
impl From<TryFromIntError> for TorshError
Source§fn from(err: TryFromIntError) -> TorshError
fn from(err: TryFromIntError) -> TorshError
Auto Trait Implementations§
impl Freeze for TorshError
impl RefUnwindSafe for TorshError
impl Send for TorshError
impl Sync for TorshError
impl Unpin for TorshError
impl UnwindSafe for TorshError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more