Skip to main content

OfficeError

Enum OfficeError 

Source
pub enum OfficeError {
Show 15 variants Io(Error), Zip(ZipError), Xml(Error), Json(Error), Encoding(FromUtf8Error), File(FileError), Parse(ParseError), Xlsx(XlsxError), Docx(DocxError), Pptx(PptxError), Format(String), UnsupportedFormat(String), Structure(String), Other(String), WithContext { error: Box<OfficeError>, context: ErrorContext, },
}
Expand description

带上下文的文档错误类型

Variants§

§

Io(Error)

IO错误

§

Zip(ZipError)

ZIP文件错误

§

Xml(Error)

XML解析错误

§

Json(Error)

JSON序列化错误

§

Encoding(FromUtf8Error)

编码错误

§

File(FileError)

文件相关错误

§

Parse(ParseError)

解析相关错误

§

Xlsx(XlsxError)

Excel特定错误

§

Docx(DocxError)

Word特定错误

§

Pptx(PptxError)

PowerPoint特定错误

§

Format(String)

格式错误

§

UnsupportedFormat(String)

不支持的文件类型

§

Structure(String)

文档结构错误

§

Other(String)

其他错误

§

WithContext

带上下文的错误

Fields

Implementations§

Source§

impl OfficeError

Source

pub fn file_not_found_with_context(path: String, context: ErrorContext) -> Self

创建带上下文的文件未找到错误

Source

pub fn parse_error_with_context(element: String, context: ErrorContext) -> Self

创建带上下文的解析错误

Source

pub fn xlsx_error_with_context(name: String, context: ErrorContext) -> Self

创建带上下文的Excel错误

Source

pub fn record(&self) -> &Self

记录错误到监控器

Source

pub fn new_and_record(error: OfficeError) -> Self

创建错误并自动记录

Source

pub fn severity(&self) -> ErrorSeverity

获取错误严重程度

Source

pub fn category(&self) -> ErrorCategory

获取错误分类

Source

pub fn error_code(&self) -> ErrorCode

获取错误码

Source

pub fn is_recoverable(&self) -> bool

判断错误是否可恢复

Source

pub fn with_context(self, context: ErrorContext) -> Self

添加错误上下文

Source

pub fn context(&self) -> Option<&ErrorContext>

获取错误上下文

Source

pub fn root_error(&self) -> &OfficeError

获取根错误(去除上下文包装)

Source

pub fn recovery_suggestion(&self) -> Option<RecoverySuggestion>

获取错误恢复建议

Source

pub fn error_chain(&self) -> Vec<&dyn Error>

获取错误链

Source

pub fn root_cause(&self) -> &dyn Error

获取根因错误

Trait Implementations§

Source§

impl Debug for OfficeError

Source§

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

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

impl Display for OfficeError

Source§

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

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

impl Error for OfficeError

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<DocxError> for OfficeError

Source§

fn from(source: DocxError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for OfficeError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for OfficeError

Source§

fn from(source: XmlError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for OfficeError

Source§

fn from(source: JsonError) -> Self

Converts to this type from the input type.
Source§

impl From<FileError> for OfficeError

Source§

fn from(source: FileError) -> Self

Converts to this type from the input type.
Source§

impl From<FromUtf8Error> for OfficeError

Source§

fn from(source: FromUtf8Error) -> Self

Converts to this type from the input type.
Source§

impl From<ParseError> for OfficeError

Source§

fn from(source: ParseError) -> Self

Converts to this type from the input type.
Source§

impl From<PptxError> for OfficeError

Source§

fn from(source: PptxError) -> Self

Converts to this type from the input type.
Source§

impl From<XlsxError> for OfficeError

Source§

fn from(source: XlsxError) -> Self

Converts to this type from the input type.
Source§

impl From<ZipError> for OfficeError

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.