56 lines
1.2 KiB
Rust
56 lines
1.2 KiB
Rust
use thiserror;
|
|
|
|
use pe_parse::error::{
|
|
MutablePEError,
|
|
PEParseError,
|
|
};
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum AppError {
|
|
#[error(transparent)]
|
|
Utf8Error(#[from] std::str::Utf8Error),
|
|
|
|
#[error(transparent)]
|
|
Io(#[from] std::io::Error),
|
|
|
|
// 未打开文件映射
|
|
#[error("文件未打开!")]
|
|
NoFileOpened,
|
|
|
|
// 文件没有初始化打开
|
|
#[error("文件未初始化打开!")]
|
|
NotInitOpenFile,
|
|
|
|
#[error(transparent)]
|
|
PeParseError(#[from] PEParseError),
|
|
|
|
#[error(transparent)]
|
|
MutablePeError(#[from] MutablePEError),
|
|
|
|
/// 初始化打开文件失败
|
|
#[error("初始化打开文件失败!: {0}")]
|
|
InitOpenFileFailed(String),
|
|
|
|
/// 无法修改文件
|
|
#[error("无法修改文件!: {0}")]
|
|
CannotModifyFile(String),
|
|
|
|
/// 节名过长
|
|
#[error("节名过长!")]
|
|
SectionNameTooLong,
|
|
|
|
#[error("打开进程失败!: {0}")]
|
|
OpenProcessError(String),
|
|
#[error("查询进程路径失败!: {0}")]
|
|
QueryFullProcessImageNameWError(String),
|
|
}
|
|
|
|
impl serde::Serialize for AppError {
|
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
where
|
|
S: serde::ser::Serializer,
|
|
{
|
|
serializer.serialize_str(self.to_string().as_ref())
|
|
}
|
|
}
|