stabilizer_ch_form_rust/error/
mod.rs1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Error, Debug)]
7pub enum Error {
8 #[error("Qubit index {0} is out of bounds for {1} qubits.")]
10 QubitIndexOutOfBounds(usize, usize),
11
12 #[error("Number of qubits must be greater than zero, got {0}.")]
14 InvalidNumQubits(usize),
15
16 #[error("Two-qubit gate requires two different qubit indices, but got the same: {0}.")]
18 DuplicateQubitIndices(usize),
19
20 #[error(
22 "Impossible projection on qubit {qubit_index}: cannot project determined state |{}> onto|{}>.",
23 if *desired { 0 } else { 1 },
24 if *desired { 1 } else { 0 }
25 )]
26 ImpossibleProjection { qubit_index: usize, desired: bool },
27
28 #[error(
30 "The qubit counts of the two states must match for {}, got {} and {}.",
31 operation,
32 left,
33 right
34 )]
35 QubitCountMismatch {
36 operation: &'static str,
37 left: usize,
38 right: usize,
39 },
40
41 #[error("The length of the permutation ({0}) must match the number of qubits ({1}).")]
43 InvalidPermutationLength(usize, usize),
44
45 #[error("The provided permutation {0:?} is not a valid permutation of qubit indices.")]
47 InvalidPermutation(Vec<usize>),
48
49 #[error("The length of the qubit state ({0}) does not match the number of qubits ({1}).")]
51 InvalidQubitStateLength(usize, usize),
52
53 #[error("Cannot discard qubit {0} because it is not in a proper state")]
55 CannotDiscardQubit(usize),
56
57 #[error("QASM parsing error: {0}")]
59 QasmParsingError(String),
60
61 #[error("Pauli string parsing error: {0}")]
63 PauliStringParsingError(String),
64
65 #[error("IO error: {0}")]
66 Io(#[from] std::io::Error),
67}