dope_runtime/executor/session/
error.rs1use dope_core::Errno;
2
3use crate::executor::{InstallError, drive, session};
4
5#[derive(Debug)]
7pub enum Error<'report, T> {
8 Drive(drive::Error),
9 Quiesce {
10 output: T,
11 drive: &'report drive::Error,
12 disarm: Option<Errno>,
13 },
14 Install {
15 cause: InstallError,
16 disarm: Option<Errno>,
17 },
18}
19
20impl<T> Error<'_, T> {
21 pub fn output(&self) -> Option<&T> {
23 match self {
24 Self::Quiesce { output, .. } => Some(output),
25 Self::Drive(_) | Self::Install { .. } => None,
26 }
27 }
28
29 pub fn cause(&self) -> session::Cause<'_> {
31 match self {
32 Self::Drive(error) => session::Cause::Drive(error),
33 Self::Quiesce { drive, disarm, .. } => session::Cause::Quiesce {
34 drive,
35 disarm: *disarm,
36 },
37 Self::Install { cause, disarm } => session::Cause::Install {
38 cause,
39 disarm: *disarm,
40 },
41 }
42 }
43}
44
45impl<T> From<drive::Error> for Error<'_, T> {
46 fn from(error: drive::Error) -> Self {
47 Self::Drive(error)
48 }
49}