Skip to main content

trait_kit/
error.rs

1// Copyright (c) 2026 Kirky.X
2// SPDX-License-Identifier: MIT
3//! Error types for Kit operations.
4
5use thiserror::Error;
6
7/// Unified trait-kit error type.
8///
9/// Follows the `ProjectNameError` naming convention used across the base workspace.
10#[derive(Debug, Error)]
11pub enum TraitKitError {
12    #[error("dependency cycle detected: {}", cycle.join(" → "))]
13    CycleDetected { cycle: Vec<&'static str> },
14
15    #[error("module `{module}` depends on `{missing}` which is not registered")]
16    DependencyMissing {
17        module: &'static str,
18        missing: &'static str,
19    },
20
21    #[deprecated(note = "typestate pattern makes this unreachable; will be removed in 0.3.0")]
22    #[error("kit is not ready; call build() first")]
23    NotReady,
24
25    #[error("module `{module}` is already registered")]
26    AlreadyRegistered { module: &'static str },
27
28    #[error("failed to build `{context}`: {source}")]
29    BuildFailed {
30        context: &'static str,
31        #[source]
32        source: Box<dyn std::error::Error + Send + 'static>,
33    },
34
35    #[error("missing capability `{key}`")]
36    MissingCapability { key: &'static str },
37
38    #[error("missing config `{key}`")]
39    MissingConfig { key: &'static str },
40}
41
42/// Convenience `Result` alias for trait-kit operations.
43#[allow(
44    dead_code,
45    reason = "public API alias reserved for future re-export; not yet used internally"
46)]
47pub type TraitKitResult<T> = std::result::Result<T, TraitKitError>;