qubit_value/numeric_comparison_error.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//! Errors that explain why runtime values cannot be numerically ordered.
10
11use qubit_datatype::DataType;
12use thiserror::Error;
13
14/// Describes why two [`crate::Value`] instances cannot be numerically ordered.
15#[must_use]
16#[derive(Debug, Clone, PartialEq, Eq, Error)]
17#[non_exhaustive]
18pub enum NumericComparisonError {
19 /// The left operand is unset but retains a declared type.
20 #[error("left value is missing: declared type is {declared}")]
21 LeftMissing {
22 /// Declared runtime type of the unset left operand.
23 declared: DataType,
24 },
25 /// The right operand is unset but retains a declared type.
26 #[error("right value is missing: declared type is {declared}")]
27 RightMissing {
28 /// Declared runtime type of the unset right operand.
29 declared: DataType,
30 },
31 /// The concrete left operand is not numeric.
32 #[error("left value is not numeric: {actual}")]
33 LeftNotNumeric {
34 /// Actual runtime type of the left operand.
35 actual: DataType,
36 },
37 /// The concrete right operand is not numeric.
38 #[error("right value is not numeric: {actual}")]
39 RightNotNumeric {
40 /// Actual runtime type of the right operand.
41 actual: DataType,
42 },
43 /// Only the left operand is NaN.
44 #[error("left value is NaN")]
45 LeftNaN,
46 /// Only the right operand is NaN.
47 #[error("right value is NaN")]
48 RightNaN,
49 /// Both operands are NaN.
50 #[error("both values are NaN")]
51 BothNaN,
52}