printobserver_core/
error.rs1use printobserver_printer_api::PrinterError;
4use printobserver_store_api::StoreError;
5use printobserver_supervisor_api::SupervisorError;
6use printobserver_types::PrintId;
7use printobserver_vision_api::VisionError;
8
9#[derive(Debug, Clone, PartialEq, Eq)]
16pub enum CoreError {
17 Store(StoreError),
19 Printer(PrinterError),
21 Vision(VisionError),
23 Supervisor(SupervisorError),
25 NoSuchPrint {
27 print_id: PrintId,
29 },
30 Unrepresentable {
32 detail: String,
34 },
35}
36
37impl core::fmt::Display for CoreError {
38 fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
39 match self {
40 Self::Store(error) => write!(formatter, "the store failed: {error}"),
41 Self::Printer(error) => write!(formatter, "the printer failed: {error}"),
42 Self::Vision(error) => write!(formatter, "the vision port failed: {error}"),
43 Self::Supervisor(error) => write!(formatter, "the supervisor failed: {error}"),
44 Self::NoSuchPrint { print_id } => write!(formatter, "there is no print {print_id}"),
45 Self::Unrepresentable { detail } => {
46 write!(formatter, "an instant is not representable: {detail}")
47 }
48 }
49 }
50}
51
52impl core::error::Error for CoreError {}
53
54impl From<StoreError> for CoreError {
55 fn from(error: StoreError) -> Self {
56 Self::Store(error)
57 }
58}