Skip to main content

trait_kit/core/
error.rs

1// Copyright (c) 2026 Kirky.X
2//
3// Licensed under the MIT License
4// See LICENSE file in the project root for full license information.
5
6//! Error types for Kit operations.
7
8use thiserror::Error;
9
10#[derive(Debug, Error)]
11pub enum KitError {
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}