use chrono::Duration;
use crate::OfficeError;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ErrorCode {
System(SystemErrorCode),
Parse(ParseErrorCode),
Format(FormatErrorCode),
Document(DocumentErrorCode),
Common(CommonErrorCode),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SystemErrorCode {
NotFound = 1001, PermissionDenied = 1002, Corrupted = 1003,
IoError = 1100, ZipError = 1101, NetworkError = 1102, }
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ParseErrorCode {
Xml = 2001, Json = 2002, Encoding = 2003,
MissingElement = 2101, InvalidAttribute = 2102, InvalidNamespace = 2103, UnsupportedVersion = 2104, }
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum FormatErrorCode {
InvalidFormat = 3001, UnsupportedFormat = 3002, VersionMismatch = 3003,
InvalidReference = 3101, InvalidValue = 3102, OutOfRange = 3103, }
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum DocumentErrorCode {
XlsxWorksheetNotFound = 4001, XlsxInvalidCellReference = 4002, XlsxInvalidFormula = 4003, XlsxInvalidStyle = 4004,
DocxStyleNotFound = 5001, DocxInvalidTableStructure = 5002, DocxInvalidParagraph = 5003, DocxBookmarkNotFound = 5004,
PptxInvalidPresentation = 6001, PptxInvalidSlide = 6002, PptxInvalidShape = 6003, PptxInvalidText = 6004, }
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum CommonErrorCode {
UnknownError = 9001, NotImplemented = 9002, InvalidOperation = 9003, Timeout = 9004, }
#[derive(Debug, Clone)]
pub struct RecoverySuggestion {
pub message: String,
pub action: RecoveryAction,
}
#[derive(Debug, Clone)]
pub enum RecoveryAction {
Retry(u32),
UseDefault,
Fallback(String),
SkipElement,
UserInput(String),
Ignore,
None,
}
pub struct RecoveryStrategy {
pub pattern: ErrorPattern, pub operation: RecoveryAction, pub max_attempts: u32, pub backoff: Duration, }
pub enum ErrorPattern {
ContinuousFailure(u32), PeriodicError(String), BurstError { threshold: u32,
time_window: Duration,
},
}