pub enum OperationErrorKind {
NotSupported {
operation: String,
reason: String,
},
InvalidParameters {
operation: String,
reason: String,
},
}Expand description
Represents the types of errors that can occur during operations related to trading strategies or other processes.
This enum categorizes errors for better debugging and handling in a structured way.
§Variants
-
NotSupported- Indicates that the requested operation is not supported for a given strategy type or context. Used when there’s an incompatibility between an operation and its execution context. -
InvalidParameters- Reflects that the operation was provided with invalid or insufficient parameters that prevent successful execution. Used when input validation fails.
§Examples
use optionstratlib_core::error::OperationErrorKind;
// Creating a NotSupported error
let error = OperationErrorKind::NotSupported {
operation: "calculate_delta".to_string(),
reason: "Not applicable for binary options".to_string()
};
// Creating an InvalidParameters error
let error = OperationErrorKind::InvalidParameters {
operation: "calculate_premium".to_string(),
reason: "Missing volatility input".to_string()
};§Use Cases
- Used in strategy implementations to signal operation compatibility issues
- Used in validation layers to report problems with input parameters
- Helps create clear error messages that guide users toward resolution
§Related Types
This error type is typically used alongside other specialized error enums in the
error module, such as StrategyError, OptionsError, and others.
Variants§
NotSupported
Operation not supported for this strategy or context
Used when an operation cannot be performed due to incompatibility with the target strategy type or other contextual constraints.
Fields
InvalidParameters
Invalid parameters for operation
Used when the input parameters for an operation are invalid, insufficient, or incompatible with the requirements of the operation.
Trait Implementations§
Source§impl Debug for OperationErrorKind
impl Debug for OperationErrorKind
Source§impl Display for OperationErrorKind
impl Display for OperationErrorKind
Source§impl Error for OperationErrorKind
impl Error for OperationErrorKind
1.30.0 · 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
use the Display impl or to_string()