Skip to content

Commit 5b8813f

Browse files
committed
refactor(vmm): use thiserror for vstate::vm::RestoreStateError
Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent 8fd3c79 commit 5b8813f

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/vmm/src/vstate/vm.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,12 @@ pub enum RestoreStateError {
9999

100100
/// Error type for [`Vm::restore_state`]
101101
#[cfg(target_arch = "aarch64")]
102-
#[derive(Debug, derive_more::From)]
103-
pub struct RestoreStateError(crate::arch::aarch64::gic::Error);
104-
#[cfg(target_arch = "aarch64")]
105-
impl std::fmt::Display for RestoreStateError {
106-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
107-
write!(f, "{}", self.0)
108-
}
102+
#[derive(Debug, thiserror::Error)]
103+
pub enum RestoreStateError {
104+
/// GIC Error
105+
#[error("{0}")]
106+
GicError(crate::arch::aarch64::gic::Error),
109107
}
110-
#[cfg(target_arch = "aarch64")]
111-
impl std::error::Error for RestoreStateError {}
112108

113109
pub type Result<T> = result::Result<T, Error>;
114110

@@ -236,7 +232,7 @@ impl Vm {
236232
) -> std::result::Result<(), RestoreStateError> {
237233
self.get_irqchip()
238234
.restore_device(mpidrs, &state.gic)
239-
.map_err(RestoreStateError)
235+
.map_err(RestoreStateError::GicError)
240236
}
241237
}
242238

0 commit comments

Comments
 (0)