Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAURE] Improved exception message for invalid num parameters #109

Open
ryanhill1 opened this issue Dec 10, 2024 · 0 comments
Open

[FEAURE] Improved exception message for invalid num parameters #109

ryanhill1 opened this issue Dec 10, 2024 · 0 comments
Labels
enhancement New feature or request error-handling Issues related to error handing and error propagation program-validation Issues related to program validation

Comments

@ryanhill1
Copy link
Member

For example, if I try to pass two parameters to the rz gate instead of just one, I get a TypeError instead of a ValidationError, and it isn't clear from the exception message what gate or line caused the error.

import pyqasm

qasm = """
OPENQASM 3;
include "stdgates.inc";

qubit[2] q;

rx(0.5) q[1];

// too many parameters
rz(0.5, 0.0) q[0];
"""

program = pyqasm.loads(qasm)

program.validate()
...
    [665] for targets in all_targets:
--> [666]     result.extend(gate_function(*targets))
    [667] return result

TypeError: <lambda>() takes 2 positional arguments but 3 were given
@ryanhill1 ryanhill1 added the enhancement New feature or request label Dec 10, 2024
@ryanhill1 ryanhill1 added program-validation Issues related to program validation error-handling Issues related to error handing and error propagation labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request error-handling Issues related to error handing and error propagation program-validation Issues related to program validation
Projects
None yet
Development

No branches or pull requests

1 participant