1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#![warn(missing_docs)]
use crate::architecture::arm::ArmError;
use crate::architecture::riscv::communication_interface::RiscvError;
use crate::config::RegistryError;
use crate::DebugProbeError;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("An error with the usage of the probe occurred")]
Probe(#[from] DebugProbeError),
#[error("A ARM specific error occured.")]
Arm(#[source] ArmError),
#[error("A RISCV specific error occured.")]
Riscv(#[source] RiscvError),
#[error("Probe could not be opened: {0}")]
UnableToOpenProbe(&'static str),
#[error("Core {0} does not exist")]
CoreNotFound(usize),
#[error("Unable to load specification for chip")]
ChipNotFound(#[from] RegistryError),
#[error("An operation could not be performed because it lacked the permission to do so: {0}")]
MissingPermissions(String),
#[error(transparent)]
Other(#[from] anyhow::Error),
#[error("A timeout occured.")]
Timeout,
#[error("Alignment error")]
MemoryNotAligned {
address: u64,
alignment: usize,
},
}
impl From<ArmError> for Error {
fn from(value: ArmError) -> Self {
match value {
ArmError::Timeout => Error::Timeout,
ArmError::MemoryNotAligned { address, alignment } => {
Error::MemoryNotAligned { address, alignment }
}
other => Error::Arm(other),
}
}
}