Skip to main content

KitError

Enum KitError 

Source
pub enum KitError {
Show 20 variants NotInstalled { name: String, }, AlreadyInstalled { name: String, path: PathBuf, }, PluginInUse { name: String, }, ManifestRead { path: PathBuf, source: Error, }, ManifestParse { path: PathBuf, source: Box<Error>, }, ManifestMissingField { field: String, path: PathBuf, }, LibraryNotFound { name: String, tried: String, }, LibraryLoad { path: PathBuf, source: Box<Error>, }, SymbolMissing { symbol: String, }, NullEntry, LockTimeout { path: PathBuf, secs: u64, }, LockIo { path: PathBuf, source: Error, }, CargoNotFound, BuildFailed { code: Option<i32>, }, BuildArtifactMissing { stem: String, dir: String, }, Http(String), Registry(String), PluginPanicked { what: String, }, NoDataDir, Io(Error),
}
Expand description

kit 的错误。

变体分两类:

Variants§

§

NotInstalled

要卸载/更新的插件没装。

Fields

§name: String

完整 crate 名。

§

AlreadyInstalled

要安装的插件已经在了。

这是刻意的:install 不覆盖已有的安装,替换请走 update。

Fields

§name: String

完整 crate 名。

§path: PathBuf

已存在的目录。

§

PluginInUse

插件的动态库仍在本进程里加载着,删不掉。

Windows 上正在 dlopen 的 .dll 无法删除;Linux/macOS 上删得掉但空间不回收。 与其赌,不如让用户换一个干净的进程。

Fields

§name: String

完整 crate 名。

§

ManifestRead

读 manifest 文件失败。

Fields

§path: PathBuf

manifest 路径。

§source: Error

底层 IO 错误。

§

ManifestParse

manifest 不是合法 TOML,或字段类型不对。

Fields

§path: PathBuf

manifest 路径。

§source: Box<Error>

底层 TOML 错误。

§

ManifestMissingField

manifest 里某个必填字段缺失或为空。

Fields

§field: String

字段名,例如 plugin.name。

§path: PathBuf

manifest 路径。

§

LibraryNotFound

安装目录里找不到符合命名规则的动态库。

Fields

§name: String

文件名主干。

§tried: String

尝试过的文件名,逗号分隔。

§

LibraryLoad

dlopen 本身失败(文件损坏、架构不符、缺依赖库)。

Fields

§path: PathBuf

动态库路径。

§source: Box<Error>

底层 libloading 错误。

§

SymbolMissing

动态库加载成功,但没有我们找的那个导出符号。

常见于“装错了东西“—— 比如把一个普通库放进了插件目录。

Fields

§symbol: String

缺失的符号名。

§

NullEntry

插件的入口函数返回了空指针。

§

LockTimeout

等安装锁超时。

Fields

§path: PathBuf

锁文件路径。

§secs: u64

等待了多少秒。

§

LockIo

锁文件本身操作失败。

Fields

§path: PathBuf

锁文件路径。

§source: Error

底层 IO 错误。

§

CargoNotFound

PATH 里没有 cargo,build-host 装不了。

调用方可以据此提示用户“装个 Rust 工具链“,或改走 prebuilt。

§

BuildFailed

cargo build 失败。stderr 已经透传给用户了(stdio 继承)。

Fields

§code: Option<i32>

进程退出码。被信号杀掉时为 None。

§

BuildArtifactMissing

编译成功了,但产物里找不到 cdylib。

Fields

§stem: String

期望的文件名主干。

§dir: String

找过的目录。

§

Http(String)

网络请求失败。字符串里带 URL 与状态码。

§

Registry(String)

registry 返回了能拿到、但不符合预期的内容。

§

PluginPanicked

跨边界调用时插件 panic 了(宿主侧 catch_unwind 捕获)。

Fields

§what: String

哪个调用点,例如 "entry()"。

§

NoDataDir

既没有 HOME 也没有等价的系统目录,数据目录定不下来。

§

Io(Error)

IO 错误。

Trait Implementations§

Source§

impl Debug for KitError

Source§

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

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

impl Display for KitError

Source§

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

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

impl Error for KitError

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 KitError

Source§

fn from(source: Error) -> 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, !>

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.