Commit c4d8bee
authored
Use rust-native errors in
* Use rust-native errors in `DAGCircuit`
This should be step 1 for splitting `PyDAGCircuit` from `DAGCircuit`.
The following commits assure that any rust accessible method for `DAGCircuit` that:
1. Does not take a `py` token;
2. Is a public method.
does not need to depend on `PyErr` to process any errors.
It is ensured that these errors:
- Maintain the level of detail that the previous ones did.
- Correctly map to the same Python exceptions as before.
The enumeration for these errors is called `DAGCircuitInnerError` (subject to change) and is implemented with `thiserror`. I chose this over `anyhow` because it is better for specifying where the error comes from based on its variant rather than the message it contains.
* Lint: Use names instead of underscores
* Add: `anyhow!` usage for `DAGCircuitError
- Use `anyhow!` for any error types that don't require tracking of any variables coming from the `DAG` or that are part of the function arguments.
- Consolidate the amount of `DAG` error variants down from 40+ to 21. Can be consolidated further.
* Fix: Existing error formatting
- Use `this_error` to fix the formatting of current errors causing conflicts with their messages.
- Add `is_var` argument to differentiate Variables and Stretches in `VariableNotInlined`.
* Fix: consolidate `RegistryAbsentObject` error.
* Add: errors for `size` and `depth`.
* Refactor: `DAGCircuitInnerError` to `DAGError`
* Fix: Add custom `From` impl for `Infallible`
- The new implementation elides `Infallible` by using a 0-variant `match` which will be valid only with `Infallible` and return nothing.
* Fix: Add context to `WireOutOfRange`
- Remove usage of `anyhow` for `WireOutOfRange`.
* Remove: `anyhow` in `General errors
We removed `anyhow` from the circuit crate and instead assumed any error of type `String` should be assigned to a `General` error.
* Rename: `RegisterRef`, `ConcreteWire` to `RegisterType`, `ShareableWire`.
* Fix: Incorrect use of qubits for clbit error
* Revert: Hiding Py tokens in classical resources.
* Fix: `panic!` when `"not a dag"` is found.
* Revert: Original bits not idle error.DAGCircuit (#16134)1 parent 3767817 commit c4d8bee
5 files changed
Lines changed: 477 additions & 324 deletions
File tree
- crates
- circuit/src
- transpiler/src/passes
- sabre
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
| 598 | + | |
598 | 599 | | |
599 | 600 | | |
600 | 601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
0 commit comments