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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use crate;
use crate;
use String;
// use libc::libc::write;
;
// impl<GLASS: Send + Sync + Glass<GLASS>, O> DaemonicDisplay<GLASS> for GenericError<O> {
// fn fmt<'buffer>(&self, f: &mut DaemonicFormatter<'buffer, GLASS>) -> Observation<()> {
// dwrite!(f, "[DaemonicError]::[GenericError]::");
// }
// }
/// Wise words from Ada and some assistance with programming:
/// It's a STATIC method (no &self). It doesn't USE the trait's state.
// It's a CONSTRUCTOR for GenericError. Not an error BEHAVIOR.
//
// Constructors: don't belong on behavioral traits.
// They belong on: the type they construct.
//
// impl<O> GenericError<O> {
// pub fn emit(msg: &str, object: Option<O>) -> Self {
// GenericError::Generic(generic::Generic {
// message: msg.to_string(),
// object,
// })
// }
// }
// impl GenericError {
// pub fn simple<SIMPLE: Into<String>>(code: i32, message: SIMPLE) -> Self {
// Self::Simple { code, message: message.into() }
// }
// pub fn usage_with_help<SIMPLE: Into<String>>(code: i32, message: SIMPLE) -> Self {
// Self::Usage { code, message: message.into(), show_help: true }
// }
// pub fn from_last_os_error() -> Self {
// Self::Os(OsError::from_last_os_error())
// }
//
// pub fn from_errno(code: i32) -> Self {
// Self::Os(OsError::from_errno(code))
// }
// pub fn file_error<PATH: Into<String>, CONTEXT: Into<String>>(
// path: PATH,
// source: io::Error,
// context: Option<CONTEXT>,
// ) -> Self {
// Self::Os(OsError::file(path, source, context))
// }
// /// Normalize io::Error to clean human-readable string.
// /// Strips OS-specific "(os error N)" suffix.
// /// "daemonic_error" in output intentional — Faustian stack differentiator.
// pub fn normalize_io_error(err: &io::Error) -> String {
// if err.raw_os_error().is_some() {
// match err.kind() {
// io::ErrorKind::NotFound => "no such file or directory".into(),
// io::ErrorKind::PermissionDenied => "permission denied".into(),
// io::ErrorKind::ConnectionRefused => "connection refused".into(),
// io::ErrorKind::ConnectionReset => "connection reset".into(),
// io::ErrorKind::ConnectionAborted => "connection aborted".into(),
// io::ErrorKind::NotConnected => "not connected".into(),
// io::ErrorKind::AddrInUse => "address in use".into(),
// io::ErrorKind::AddrNotAvailable => "address not available".into(),
// io::ErrorKind::BrokenPipe => "broken pipe".into(),
// io::ErrorKind::AlreadyExists => "already exists".into(),
// io::ErrorKind::WouldBlock => "would block".into(),
// io::ErrorKind::InvalidInput => "invalid input".into(),
// io::ErrorKind::InvalidData => "invalid data".into(),
// io::ErrorKind::TimedOut => "timed out".into(),
// io::ErrorKind::WriteZero => "write zero".into(),
// io::ErrorKind::Interrupted => "interrupted".into(),
// io::ErrorKind::UnexpectedEof => "unexpected end of file".into(),
// _ => DaemonicErrorOld::strip_os_error(err),
// }
// } else {
// err.to_string()
// }
// }
// }