1use thiserror::Error;
2
3pub type Result<T> = core::result::Result<T, HotpatchError>;
4
5#[derive(Debug, Error)]
6pub enum HotpatchError {
7 #[error("failed to load patch library at {path}: {source}")]
8 LibraryLoad {
9 path: String,
10 #[source]
11 source: libloading::Error,
12 },
13
14 #[error("required export symbol {symbol} not found: {source}")]
15 MissingExport {
16 symbol: &'static str,
17 #[source]
18 source: libloading::Error,
19 },
20
21 #[error("ABI mismatch: expected magic 0x{expected_magic:08x}/v{expected_version}, got 0x{got_magic:08x}/v{got_version}")]
22 AbiMismatch {
23 expected_magic: u32,
24 got_magic: u32,
25 expected_version: u16,
26 got_version: u16,
27 },
28
29 #[error("invalid patch module: {0}")]
30 InvalidModule(String),
31
32 #[error("symbol not found in runtime registry: {0}")]
33 SymbolNotFound(String),
34
35 #[error("symbol already has a fallback implementation: {0}")]
36 FallbackAlreadyRegistered(String),
37
38 #[error("failed to run module lifecycle hook '{hook}' for {module}: status {status}")]
39 LifecycleFailed {
40 module: String,
41 hook: &'static str,
42 status: i32,
43 },
44}