daemonic_error 0.1.2

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)
pub(crate) enum Entity {
	Shade(shade::ShadeError),
}
pub(crate) mod shade {
	use clock::ShadeClockError;
	use walker::Walker;
	#[derive(Debug)]
	pub(crate) enum ShadeError {
		Ingestion(ingestion::Ingestion),
		ClockError(ShadeClockError),
		WalkerError(Walker),
	}
	mod walker {
		use alloc::string::String;
		use alloc::vec::Vec;
		use crate::PathBuf;
		
		#[derive(Debug)]
		pub(crate) enum Walker {
			ClockError(walkerclock::WalkerClockError),
			// WalkerError Read Source File failure, uses fs::read_to_string
			FileRead(FileRead),
			DirRead(DirRead),
			DirEntry(DirEntry),
			// WalkerError Unsupported input language, tree-sitter thrown flag
			UnsupportedLanguage(UnsupportedLanguage),
			// WalkerError Parser thrown error, likely from SymbolTree dep or TreeSitter, indicates language set failure.
			ParseErrorLangSet(ParseErrorLangSet),
			ParseErrorFile(ParseErrorFile),
			Cancelled(Cancelled),
			EnumerationCancelled(EnumerationCancelled),
			TaskPanic(TaskPanic),
			Extraction(Extraction),
			SpawnError(SpawnError),
			EnumerationFailed(EnumerationFailed),
			MemoryAccessError(MemoryAccessError),
			ParseError(ParseError),
			EntropyTermination(EntropyTermination),
		}
		#[derive(Debug)]
		struct FileRead {
			filename: Vec<PathBuf>,
			error_context: String,
		}
		#[derive(Debug)]
		struct DirRead {
			filename: Vec<PathBuf>,
			error_context: String,
		}
		#[derive(Debug)]
		struct DirEntry {
			filename: Vec<PathBuf>,
			error_context: String,
		}
		#[derive(Debug)]
		struct UnsupportedLanguage {
			language: String,
			filename: Vec<PathBuf>,
		}
		#[derive(Debug)]
		struct ParseErrorLangSet {
			error_context: String,
		}
		#[derive(Debug)]
		struct ParseErrorFile {
			filename: String,
		}
		#[derive(Debug)]
		struct Cancelled {
			walker_id: u64,
			file_id: Option<PathBuf>,
		}
		#[derive(Debug)]
		struct EnumerationCancelled {
			walker_id: u64,
			comment: String,
		}
		#[derive(Debug)]
		struct TaskPanic {
			walker_id: u64,
			file_id: Vec<PathBuf>,
			panic_message: String,
		}
		#[derive(Debug)]
		struct Extraction {
			file: Vec<PathBuf>,
			error: String,
		}
		#[derive(Debug)]
		struct SpawnError {
			error: String,
		}
		#[derive(Debug)]
		struct EnumerationFailed {
			comment: String,
		}
		#[derive(Debug)]
		struct MemoryAccessError {
			pid: u32,
			error_context: String,
		}
		#[derive(Debug)]
		struct ParseError {
			filename: Vec<PathBuf>,
			error_context: String,
		}
		#[derive(Debug)]
		struct EntropyTermination {
			path: PathBuf,
			comment: String,
		}
		
		mod walkerclock {
			use alloc::string::String;
			
			#[derive(Debug)]
			pub(crate) enum WalkerClockError {
				/// Clock overflow (approaching u64::MAX)
				WalkerClockOverflow {
					current: u64,
					attempted: u64,
					comment: Option<String>,
				},
				WalkerClockApproachingOverflow {
					current: u64,
					comment: Option<String>,
				},
				/// Invalid duration (end < start)
				WalkerClockInvalidDuration {
					start: u64,
					end: u64,
				},
				WalkerClockClockError {
					context: String,
				},
				WalkerClockClockErrorExt {
					context: String,
					extension: String,
				},
				WalkerClockClockUpdateFailure {
					context: String,
					comment: String,
				},
			}
		}
	}
	mod clock {
		use alloc::string::String;
		
		#[derive(Debug)]
		pub enum ShadeClockError {
			/// Clock overflow (approaching u64::MAX)
			ShadeClockOverflow(ShadeClockOverflow),
			ShadeClockApproachingOverflow(ShadeClockApproachingOverflow),
			/// Invalid duration (end < start)
			ShadeClockInvalidDuration(ShadeClockInvalidDuration),
			ShadeClockClockError(ShadeClockClockError),
			ShadeClockClockErrorExt(ShadeClockErrorExt),
			ShadeClockClockUpdateFailure(ShadeClockClockUpdateFailure),
		}
		#[derive(Debug)]
		struct ShadeClockClockUpdateFailure {
			context: String,
			comment: String,
		}
		#[derive(Debug)]
		struct ShadeClockErrorExt {
			context: String,
			extension: String,
		}
		#[derive(Debug)]
		struct ShadeClockOverflow {
			current: u64,
			attempted: u64,
			comment: Option<String>,
		}
		#[derive(Debug)]
		struct ShadeClockApproachingOverflow {
			current: u64,
			comment: Option<String>,
		}
		#[derive(Debug)]
		struct ShadeClockInvalidDuration {
			start: u64,
			end: u64,
		}
		#[derive(Debug)]
		struct ShadeClockClockError {
			context: String,
		}
	}
	mod ingestion {
		use alloc::string::String;
		
		/// im aware this seems like overkill for a single failure mode but
		/// this enum will grow as the ingestion logic deepens.
		// use crate::{
		// 	DaemonicError,
		// 	ErrorContext,
		// 	Position,
		// 	Timestamp,
		// 	EmissionGuarantee,
		// 	daemonic::{
		// 		daemonic_contract::{
		// 			daemonic_result::{
		// 				diagnostic::Diagnostic,
		// 				subdiagnostic::Subdiagnostic,
		// 			}
		// 		}
		// 	},
		// };
		
		#[derive(Debug)]
		pub(crate) enum Ingestion {
			IngestionFailure(IngestionFailure),
		}
		#[derive(Debug)]
		struct IngestionFailure {
			error_context: String,
			comment: String,
		}
		
		// fn ctx(&self) -> ErrorContext {
		// 	match self {
		// 		Self::Configuration { context, comment } => {
		// 			ctx!("Shade", "Configuration",
		// format!("Daemonic Error: SHADE Configuration Error. Context: {context:#?} \
		// Comment: {comment:#?}")
		// )
		// 		}
		// 		Self::IngestionFailure { error_context, comment } => {
		// 			ctx!("Shade", "Ingestion",
		// format!("Daemonic Error: SHADE Ingestion Error. Context: {error_context:#?} \
		// Comment: {comment:#?}")
		// )
		// 		}
		// 	}
		// }
	}
	// impl DaemonicError<'_> for NoShade {
	// 	fn ctx(&self) -> ErrorContext {
	// 		match self {
	// 			Self::FileSystem { path, error_context } =>
	// 				ctx!("Shade", "FileRead",
	// format!("Daemonic Error::FileError {path:#?} Context FileRead() Failure Context: {error_context:#?} — GLASS SHATTERED")),
	// 			Self::RecursivePoolWalker { error_context } =>
	// 				ctx!("Shade", "RecursivePoolWalker",
	// format!("Daemonic Error::RecursivePoolWalker {error_context:#?} Context RecursivePoolWalker")
	// ),
	// 			Self::RequestSerializationError { context } =>
	// 				ctx!("Shade", "RequestSerialization",
	// format!("Daemonic Error::RequestSerializationError {context:#?}")
	// ),
	// 			Self::CoordinatorReadError { context } =>
	// 				ctx!("Shade", "CoordinatorRead",
	// format!("Daemonic Error::CoordinatorReadError {context:#?}")
	// ),
	// 			Self::CoordinatorWriteError { context } =>
	// 				ctx!("Shade", "CoordinatorWrite",
	// format!("Daemonic Error::CoordinatorWriteError {context:#?}")
	// ),
	// 			Self::CoordinatorStdninFlushError { context } =>
	// 				ctx!("Shade", "CoordinatorStdninFlush",
	// format!("Daemonic Error::CoordinatorStdninFlushError {context:#?}")
	// ),
	// 			Self::CoordinatorResponseError { context } =>
	// 				ctx!("Shade", "CoordinatorResponse",
	// format!("Daemonic Error::CoordinatorResponseError(generic) {context:#?}")
	// ),
	// 			Self::DaemonDeath { broken_sword, declaration } =>
	// 				ctx!("Shade", "DaemonDeath",
	// format!("Daemonic Error::DaemonDeath Daemon Declared their own death context: {broken_sword:#?}. Declaration: {declaration:#?}")
	// ),
	// 			Self::CoordinatorResponseMalformed { context, } =>
	// 				ctx!("Shade", "CoordinatorResponseMalformed",
	// format!("Daemonic Error:: Invalid or Malformed Coordinator response. Context: {context:#?}")
	// ),
	// 			Self::CoordinatorBinaryError { context, error_context } =>
	// 				ctx!("Shade", "CoordinatorBinary",
	// format!("Daemonic Error: {error_context:#?}. Error passed up from bin: {context:#?}")
	// ),
	// 			Self::ClockError(context) =>
	// 				ctx!("Shade", "ClockError",
	// format!("Daemonic Error: Clock Error {context:#?} <UNK> GLASS SHATTERED, TEMPORAL STACK UNWIND INITIATING (in dev, todo)")
	// ),
	// 			Self::Configuration { context, comment } => {
	// 				ctx!("Shade", "Configuration",
	// format!("Daemonic Error: SHADE Configuration Error. Context: {context:#?} \
	// Comment: {comment:#?}")
	// )
	// 			}
	// 			Self::IngestionFailure { error_context, comment } => {
	// 				ctx!("Shade", "Ingestion",
	// format!("Daemonic Error: SHADE Ingestion Error. Context: {error_context:#?} \
	// Comment: {comment:#?}")
	// )
	// 			}
	// 		}
	// 	}
	// }
	#[derive(Debug)]
	struct NoShade;
}