Skip to main content

DocError

Enum DocError 

Source
#[non_exhaustive]
pub enum DocError { Io(Error), Zip(String), Format(String), Template { placeholder: String, message: String, }, Conversion { field: String, value: String, message: String, }, Unsupported(String), Document(String), }
Expand description

库统一错误枚举。

Java EasyExcel 将错误分散在七个 RuntimeException 子类中; 本枚举将它们合并为一个惯用的 Rust 类型。

对应 Java: com.alibaba.excel.exception.ExcelAnalysisExceptionExcelGenerateExceptionExcelDataConvertException

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Io(Error)

I/O 错误,包装 std::io::Error

对应 Java: IOException

§

Zip(String)

ZIP 包错误(来自 docx-rs 打包)。

对应 Java: ExcelAnalysisException 中的 ZIP 相关错误

§

Format(String)

无效或不支持的文档格式。

对应 Java: ExcelAnalysisException("The supplied file was not supported")

§

Template

模板占位符无法解析或处理。

对应 Java: ExcelAnalysisException 中的模板相关错误(easyexcel-template)

Fields

§placeholder: String

导致错误的占位符标记。

§message: String

人类可读的描述。

§

Conversion

单元格或字段值无法与目标类型互转。

对应 Java: com.alibaba.excel.exception.ExcelDataConvertException

Fields

§field: String

字段或列名。

§value: String

转换失败的值。

§message: String

人类可读的描述。

§

Unsupported(String)

请求的操作不被当前格式或配置支持。

对应 Java: UnsupportedOperationException

§

Document(String)

通用文档级错误。

对应 Java: ExcelAnalysisException / ExcelGenerateException

Trait Implementations§

Source§

impl Debug for DocError

Source§

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

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

impl Display for DocError

Source§

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

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

impl Error for DocError

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<Error> for DocError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<ZipError> for DocError

Source§

fn from(e: 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> 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 = !

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.