Skip to content

Commit

Permalink
Add reason code to error message (#1072)
Browse files Browse the repository at this point in the history
* Add reason code to error message

* add reno
  • Loading branch information
kt474 authored Sep 13, 2023
1 parent 3cccebd commit a52f8d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qiskit_ibm_runtime/runtime_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,15 @@ def _set_status(self, job_response: Dict) -> None:
"""
try:
reason = job_response["state"].get("reason")
reason_code = job_response["state"].get("reason_code")
if reason:
# TODO remove this in https://github.com/Qiskit/qiskit-ibm-runtime/issues/989
if reason.upper() == "RAN TOO LONG":
self._reason = reason.upper()
else:
self._reason = reason
if reason_code:
self._reason = f"Error code {reason_code}; {self._reason}"
self._status = self._status_from_job_response(job_response)
except KeyError:
raise IBMError(f"Unknown status: {job_response['state']['status']}")
Expand All @@ -489,6 +492,7 @@ def _error_msg_from_job_response(self, response: Dict) -> str:
Error message.
"""
status = response["state"]["status"].upper()

job_result_raw = self._download_external_result(
self._api_client.job_results(job_id=self.job_id())
)
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/error-codes-82a392efad5963da.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
upgrade:
- |
Job error messages now include the error code. Error codes can be found in
https://docs.quantum-computing.ibm.com/errors.

0 comments on commit a52f8d3

Please sign in to comment.