qubit_validator/binding/execution_error_kind.rs
1// =============================================================================
2// Copyright (c) 2025 - 2026 Haixing Hu.
3//
4// SPDX-License-Identifier: Apache-2.0
5//
6// Licensed under the Apache License, Version 2.0.
7// =============================================================================
8
9//! Execution error kinds.
10
11use std::fmt::Display;
12use std::fmt::Formatter;
13use std::fmt::Result;
14
15/// A failure in the validation execution infrastructure.
16///
17/// # Examples
18///
19/// ```
20/// use qubit_validator::ExecutionErrorKind;
21///
22/// let kind = ExecutionErrorKind::InputTypeMismatch;
23/// assert_eq!(kind.to_string(), "input type mismatch");
24/// ```
25#[must_use]
26#[derive(Clone, Copy, Debug, Eq, PartialEq)]
27#[non_exhaustive]
28pub enum ExecutionErrorKind {
29 /// The supplied input has the wrong erased type.
30 InputTypeMismatch,
31 /// The validation selection contains no matching validation path.
32 InvalidSelection,
33 /// A dependency has the wrong erased type.
34 DependencyTypeMismatch,
35 /// A required dependency value is absent.
36 MissingRequiredDependencyValue,
37 /// A named dependency value is supplied more than once.
38 DuplicateDependencyBinding,
39 /// A named dependency does not exist in the selected signature.
40 UnknownDependencyBinding,
41 /// A declared dependency value was not supplied by name.
42 MissingDependencyBinding,
43 /// A property could not be read.
44 PropertyReadFailed,
45 /// Traversal exceeded an execution budget.
46 TraversalLimit,
47 /// A prepared adapter returned an invalid protocol result.
48 AdapterContractViolation,
49 /// An external operation failed.
50 ExternalFailure,
51}
52
53impl Display for ExecutionErrorKind {
54 /// Formats the stable human-readable error category.
55 fn fmt(&self, formatter: &mut Formatter<'_>) -> Result {
56 let name = match self {
57 Self::InputTypeMismatch => "input type mismatch",
58 Self::InvalidSelection => "invalid validation selection",
59 Self::DependencyTypeMismatch => "dependency type mismatch",
60 Self::MissingRequiredDependencyValue => "missing required dependency value",
61 Self::DuplicateDependencyBinding => "duplicate dependency binding",
62 Self::UnknownDependencyBinding => "unknown dependency binding",
63 Self::MissingDependencyBinding => "missing dependency binding",
64 Self::PropertyReadFailed => "property read failed",
65 Self::TraversalLimit => "traversal limit exceeded",
66 Self::AdapterContractViolation => "adapter contract violation",
67 Self::ExternalFailure => "external failure",
68 };
69 formatter.write_str(name)
70 }
71}