daemonic_error 0.1.1

Errors that compose, predict, and leave receipts - Compose: algebraic combination (in active development) - Predict: Glass/Severity - Receipts: audit trail, position, checksum - Reflection: Runtime Reflection through TopologySegment (in active development)
use crate::daemonic::glass::{Glass, Observation};
use crate::daemonic::{Anchor, SemanticAnchor, TopologySegment};
use alloc::string::String;
// use libc::libc::write;
pub struct ZeroSizeObject;
pub enum GenericError<O = ZeroSizeObject> {
	Generic(Generic<O>),
	Simple(Simple),
	InvalidSymbol(InvalidSymbol),
	InvalidInput(InvalidInput),
}
// 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]::");
//     }
// }
pub(crate) struct Generic<O>
	where
		Self: Sized,
{
	pub message: String,
	pub object: Option<O>,
}

pub(crate) struct Simple {
	code: i32,
	message: String,
}
pub(crate) struct InvalidSymbol {
	reason: String,
}
pub(crate) struct InvalidInput {
	reason: String,
}

// 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()
// 		}
// 	}
// }