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

Qiskit / qiskit / 14968441393

12 May 2025 09:14AM CUT coverage: 88.732% (+0.01%) from 88.722%
14968441393

Pull #14259

github

web-flow
Merge 9a184f362 into c92f09265
Pull Request #14259: Improve QkCircuit C API docs

76064 of 85723 relevant lines covered (88.73%)

429734.04 hits per line

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

0.0
/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_accelerate::sparse_observable::ArithmeticError;
14
use thiserror::Error;
15

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

27
/// Integer exit codes returned to C.
28
#[repr(u32)]
29
pub enum ExitCode {
30
    /// Success.
31
    Success = 0,
32
    /// Error related to data input.
33
    CInputError = 100,
34
    /// Unexpected null pointer.
35
    NullPointerError = 101,
36
    /// Pointer is not aligned to expected data.
37
    AlignmentError = 102,
38
    /// Index out of bounds.
39
    IndexError = 103,
40
    /// Error related to arithmetic operations or similar.
41
    ArithmeticError = 200,
42
    /// Mismatching number of qubits.
43
    MismatchedQubits = 201,
44
}
45

46
impl From<ArithmeticError> for ExitCode {
47
    fn from(value: ArithmeticError) -> Self {
×
48
        match value {
×
49
            ArithmeticError::MismatchedQubits { left: _, right: _ } => ExitCode::MismatchedQubits,
×
50
        }
×
51
    }
×
52
}
53

54
impl From<CInputError> for ExitCode {
55
    fn from(value: CInputError) -> Self {
×
56
        match value {
×
57
            CInputError::AlignmentError => ExitCode::AlignmentError,
×
58
            CInputError::NullPointerError => ExitCode::NullPointerError,
×
59
            CInputError::IndexError => ExitCode::IndexError,
×
60
        }
61
    }
×
62
}
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

© 2025 Coveralls, Inc