Skip to main content

k580_core/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error, Clone, PartialEq, Eq)]
4pub enum ValidationError {
5    #[error("address range {start:#06X}..{end:#06X} is outside 64 KiB memory")]
6    MemoryRange { start: u16, end: u32 },
7}
8
9#[derive(Debug, Error, Clone, PartialEq, Eq)]
10pub enum DecodeError {
11    #[error("undocumented opcode {0:#04X}")]
12    UndocumentedOpcode(u8),
13    #[error("invalid interrupt vector opcode {0:#04X}")]
14    InvalidInterruptVector(u8),
15}
16
17#[derive(Debug, Error, Clone, PartialEq, Eq)]
18pub enum PortError {
19    #[error("invalid I/O port {0:#04X}")]
20    InvalidPort(u8),
21    #[error("device is not ready")]
22    NotReady,
23    #[error("device is busy")]
24    Busy,
25    #[error("device operation timed out")]
26    Timeout,
27    #[error("device is disconnected")]
28    Disconnected,
29    #[error("path not found: {0}")]
30    PathNotFound(String),
31    #[error("permission denied: {0}")]
32    PermissionDenied(String),
33    #[error("I/O error: {0}")]
34    Io(String),
35    #[error("protocol error: {0}")]
36    Protocol(String),
37}
38
39#[derive(Debug, Error, Clone, PartialEq, Eq)]
40pub enum CoreError {
41    #[error(transparent)]
42    Decode(#[from] DecodeError),
43    #[error(transparent)]
44    Port(#[from] PortError),
45}