1#[derive(thiserror::Error, Debug)]
4pub enum Error {
6 #[error("Missing key for argument {argument}")]
7 MissingArgKey {
9 argument: String,
11 },
12 #[error("Missing value for argument {argument}")]
13 MissingArgValue {
15 argument: String,
17 },
18 #[error("Invalid boolean value {name} ({val})")]
19 InvalidBool {
21 name: String,
23 val: String,
25 },
26 #[error(
27 "Setting the QEMU plugin uninstall callback was attempted concurrently and this attempt failed."
28 )]
29 ConcurrentPluginUninstallCallbackSet,
31 #[error(
32 "Setting the QEMU plugin reset callback was attempted concurrently and this attempt failed."
33 )]
34 ConcurrentPluginResetCallbackSet,
36 #[error("Invalid state for plugin reset callback")]
37 PluginResetCallbackState,
39 #[error("Invalid instruction index {index} for translation block of size {size}")]
40 InvalidInstructionIndex {
42 index: usize,
44 size: usize,
46 },
47 #[error("No disassembly string available for instruction")]
48 NoDisassemblyString,
50 #[error("Invalid size {size} for read of register {name}")]
51 InvalidRegisterReadSize {
53 name: String,
55 size: usize,
57 },
58 #[error("Error while reading register {name}")]
59 RegisterReadError {
61 name: String,
63 },
64 #[error("Error while writing register {name}")]
65 RegisterWriteError {
67 name: String,
69 },
70 #[cfg(not(any(
71 feature = "plugin-api-v0",
72 feature = "plugin-api-v1",
73 feature = "plugin-api-v2",
74 feature = "plugin-api-v3"
75 )))]
76 #[error("Error while reading {len} bytes from virtual address {addr:#x}")]
77 VaddrReadError {
79 addr: u64,
81 len: u32,
83 },
84 #[cfg(not(any(
85 feature = "plugin-api-v0",
86 feature = "plugin-api-v1",
87 feature = "plugin-api-v2",
88 feature = "plugin-api-v3",
89 feature = "plugin-api-v4"
90 )))]
91 #[error("Error while writing {len} bytes to virtual address {addr:#x}")]
92 VaddrWriteError {
94 addr: u64,
96 len: u32,
98 },
99 #[cfg(not(any(
100 feature = "plugin-api-v0",
101 feature = "plugin-api-v1",
102 feature = "plugin-api-v2",
103 feature = "plugin-api-v3",
104 feature = "plugin-api-v4"
105 )))]
106 #[error("Error while reading {len} bytes from hardware address {addr:#x}: {result}")]
107 HwaddrReadError {
109 addr: u64,
111 len: u32,
113 result: crate::HwaddrOperationResult,
115 },
116 #[cfg(not(any(
117 feature = "plugin-api-v0",
118 feature = "plugin-api-v1",
119 feature = "plugin-api-v2",
120 feature = "plugin-api-v3",
121 feature = "plugin-api-v4"
122 )))]
123 #[error("Error while writing {len} bytes to hardware address {addr:#x}: {result}")]
124 HwaddrWriteError {
126 addr: u64,
128 len: u32,
130 result: crate::HwaddrOperationResult,
132 },
133 #[cfg(not(any(
134 feature = "plugin-api-v0",
135 feature = "plugin-api-v1",
136 feature = "plugin-api-v2",
137 feature = "plugin-api-v3",
138 feature = "plugin-api-v4"
139 )))]
140 #[error("Error while translating virtual address {vaddr:#x} to hardware address")]
141 VaddrTranslateError {
143 vaddr: u64,
145 },
146 #[error("Error while setting global plugin instance")]
147 PluginInstanceSetError,
149 #[error(transparent)]
150 StdUtf8Error(#[from] std::str::Utf8Error),
152 #[error(transparent)]
153 Infallible(#[from] core::convert::Infallible),
155 #[error(transparent)]
156 LayoutError(#[from] std::alloc::LayoutError),
158 #[error(transparent)]
159 TryFromSliceError(#[from] std::array::TryFromSliceError),
161 #[error(transparent)]
162 BorrowError(#[from] std::cell::BorrowError),
164 #[error(transparent)]
165 BorrowMutError(#[from] std::cell::BorrowMutError),
167 #[error(transparent)]
168 CharTryFromError(#[from] std::char::CharTryFromError),
170 #[error(transparent)]
171 DecodeUtf16Error(#[from] std::char::DecodeUtf16Error),
173 #[error(transparent)]
174 ParseCharError(#[from] std::char::ParseCharError),
176 #[error(transparent)]
177 TryFromCharError(#[from] std::char::TryFromCharError),
179 #[error(transparent)]
180 TryReserveError(#[from] std::collections::TryReserveError),
182 #[error(transparent)]
183 JoinPathsError(#[from] std::env::JoinPathsError),
185 #[error(transparent)]
186 VarError(#[from] std::env::VarError),
188 #[error(transparent)]
189 FromBytesUntilNulError(#[from] std::ffi::FromBytesUntilNulError),
191 #[error(transparent)]
192 FromBytesWithNulError(#[from] std::ffi::FromBytesWithNulError),
194 #[error(transparent)]
195 FromVecWithNulError(#[from] std::ffi::FromVecWithNulError),
197 #[error(transparent)]
198 IntoStringError(#[from] std::ffi::IntoStringError),
200 #[error(transparent)]
201 NulError(#[from] std::ffi::NulError),
203 #[error(transparent)]
204 FmtError(#[from] std::fmt::Error),
206 #[error(transparent)]
207 FsTryLockError(#[from] std::fs::TryLockError),
209 #[error(transparent)]
210 IoError(#[from] std::io::Error),
212 #[error(transparent)]
213 AddrParseError(#[from] std::net::AddrParseError),
215 #[error(transparent)]
216 ParseFloatError(#[from] std::num::ParseFloatError),
218 #[error(transparent)]
219 ParseIntError(#[from] std::num::ParseIntError),
221 #[error(transparent)]
222 TryFromIntError(#[from] std::num::TryFromIntError),
224 #[error(transparent)]
225 StripPrefixError(#[from] std::path::StripPrefixError),
227 #[error(transparent)]
228 ParseBoolError(#[from] std::str::ParseBoolError),
230 #[error(transparent)]
231 FromUtf8Error(#[from] std::string::FromUtf8Error),
233 #[error(transparent)]
234 FromUtf16Error(#[from] std::string::FromUtf16Error),
236 #[error(transparent)]
237 RecvError(#[from] std::sync::mpsc::RecvError),
239 #[error(transparent)]
240 RecvTimeoutError(#[from] std::sync::mpsc::RecvTimeoutError),
242 #[error(transparent)]
243 TryRecvError(#[from] std::sync::mpsc::TryRecvError),
245 #[error(transparent)]
246 AccessError(#[from] std::thread::AccessError),
248 #[error(transparent)]
249 SystemTimeError(#[from] std::time::SystemTimeError),
251 #[error(transparent)]
252 TryFromFloatSecsError(#[from] std::time::TryFromFloatSecsError),
254 #[cfg(windows)]
255 #[error(transparent)]
256 InvalidHandleError(#[from] std::os::windows::io::InvalidHandleError),
258 #[cfg(windows)]
259 #[error(transparent)]
260 NullHandleError(#[from] std::os::windows::io::NullHandleError),
262 #[cfg(feature = "anyhow")]
263 #[error(transparent)]
264 AnyhowError(#[from] anyhow::Error),
266 #[error(transparent)]
267 BoxedError(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
269}
270
271#[allow(dead_code)]
272fn _assert_error_is_send_sync() {
274 fn assert_send_sync<T: Send + Sync>() {}
275 assert_send_sync::<Error>();
276}
277
278pub type Result<T> = std::result::Result<T, Error>;