use std::path::PathBuf; #[derive(Debug, thiserror::Error)] pub enum LintError { #[error("无法读取 {path}: {source}")] Io { path: PathBuf, #[source] source: std::io::Error, }, #[error("{path} 不是有效 UTF-8:{source}")] Utf8 { path: PathBuf, #[source] source: std::str::Utf8Error, }, #[error("协议错误:{0}")] Protocol(String), #[error("Marqdo 核心调用失败:{0}")] Core(String), #[error("{0}")] UnsafeFix(String), #[error("配置错误:{0}")] Config(String), } pub type Result = std::result::Result; impl From for String { fn from(error: LintError) -> Self { error.to_string() } } pub fn io(path: impl Into, source: std::io::Error) -> LintError { LintError::Io { path: path.into(), source, } }