• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / qiskit / 18161853567

01 Oct 2025 12:17PM UTC coverage: 88.237% (-0.07%) from 88.303%
18161853567

Pull #14837

github

web-flow
Merge 32f10218e into cde5f55d8
Pull Request #14837: Add ``QkParam`` to the C API

240 of 347 new or added lines in 3 files covered. (69.16%)

8 existing lines in 2 files now uncovered.

93119 of 105533 relevant lines covered (88.24%)

1172951.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

28.57
/crates/cext/src/exit_codes.rs
1
// This code is part of Qiskit.
2
//
3
// (C) Copyright IBM 2024
4
//
5
// This code is licensed under the Apache License, Version 2.0. You may
6
// obtain a copy of this license in the LICENSE.txt file in the root directory
7
// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
//
9
// Any modifications or derivative works of this code must retain this
10
// copyright notice, and modified files need to carry a notice indicating
11
// that they have been altered from the originals.
12

13
use qiskit_circuit::parameter::parameter_expression::ParameterError;
14
use qiskit_quantum_info::sparse_observable::ArithmeticError;
15
use qiskit_transpiler::target::TargetError;
16
use thiserror::Error;
17

18
/// Errors related to C input.
19
#[derive(Error, Debug)]
20
pub enum CInputError {
21
    #[error("Unexpected null pointer.")]
22
    NullPointerError,
23
    #[error("Non-aligned memory.")]
24
    AlignmentError,
25
    #[error("Index out of bounds.")]
26
    IndexError,
27
}
28

29
/// Integer exit codes returned to C.
30
#[repr(u32)]
31
#[derive(PartialEq, Eq, Debug)]
32
pub enum ExitCode {
33
    /// Success.
34
    Success = 0,
35
    /// Error related to data input.
36
    CInputError = 100,
37
    /// Unexpected null pointer.
38
    NullPointerError = 101,
39
    /// Pointer is not aligned to expected data.
40
    AlignmentError = 102,
41
    /// Index out of bounds.
42
    IndexError = 103,
43
    /// Duplicate index.
44
    DuplicateIndexError = 104,
45
    /// Error related to arithmetic operations or similar.
46
    ArithmeticError = 200,
47
    /// Mismatching number of qubits.
48
    MismatchedQubits = 201,
49
    /// Matrix is not unitary.
50
    ExpectedUnitary = 202,
51
    /// Target related error
52
    TargetError = 300,
53
    /// Instruction already exists in the Target
54
    TargetInstAlreadyExists = 301,
55
    /// Properties with incorrect qargs was added
56
    TargetQargMismatch = 302,
57
    /// Trying to query into the target with non-existent qargs.
58
    TargetInvalidQargsKey = 303,
59
    /// Querying an operation that doesn't exist in the Target.
60
    TargetInvalidInstKey = 304,
61
    /// Transpilation failed
62
    TranspilerError = 400,
63
}
64

65
impl From<ArithmeticError> for ExitCode {
66
    fn from(value: ArithmeticError) -> Self {
×
67
        match value {
×
68
            ArithmeticError::MismatchedQubits { left: _, right: _ } => ExitCode::MismatchedQubits,
×
69
        }
70
    }
×
71
}
72

73
impl From<CInputError> for ExitCode {
74
    fn from(value: CInputError) -> Self {
×
75
        match value {
×
76
            CInputError::AlignmentError => ExitCode::AlignmentError,
×
77
            CInputError::NullPointerError => ExitCode::NullPointerError,
×
78
            CInputError::IndexError => ExitCode::IndexError,
×
79
        }
80
    }
×
81
}
82

83
impl From<TargetError> for ExitCode {
84
    fn from(value: TargetError) -> Self {
12✔
85
        match value {
12✔
86
            TargetError::InvalidKey(_) => ExitCode::TargetInvalidInstKey,
4✔
87
            TargetError::AlreadyExists(_) => ExitCode::TargetInstAlreadyExists,
4✔
88
            TargetError::QargsMismatch {
89
                instruction: _,
90
                arguments: _,
91
            } => ExitCode::TargetQargMismatch,
×
92
            TargetError::InvalidQargsKey {
93
                instruction: _,
94
                arguments: _,
95
            } => ExitCode::TargetInvalidQargsKey,
4✔
96
            _ => ExitCode::TargetError,
×
97
        }
98
    }
12✔
99
}
100

101
impl From<ParameterError> for ExitCode {
NEW
102
    fn from(_value: ParameterError) -> Self {
×
NEW
103
        ExitCode::ArithmeticError
×
NEW
104
    }
×
105
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc