diff --git a/qiskit_ibm_runtime/runtime_job.py b/qiskit_ibm_runtime/runtime_job.py index b6d9eeb8d..eff9c14fd 100644 --- a/qiskit_ibm_runtime/runtime_job.py +++ b/qiskit_ibm_runtime/runtime_job.py @@ -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']}") @@ -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()) ) diff --git a/releasenotes/notes/error-codes-82a392efad5963da.yaml b/releasenotes/notes/error-codes-82a392efad5963da.yaml new file mode 100644 index 000000000..5f95903a0 --- /dev/null +++ b/releasenotes/notes/error-codes-82a392efad5963da.yaml @@ -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. \ No newline at end of file