From 4eb26eb28c93f169c069d7ac4fa3d2c3cb7e5800 Mon Sep 17 00:00:00 2001 From: "A.M. Santana" Date: Mon, 17 Jul 2023 21:20:14 +0000 Subject: [PATCH 1/2] add runtime error for failed job Signed-off-by: A.M. Santana --- .../platform/default/rest/helpers/ionq/IonQServerHelper.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runtime/cudaq/platform/default/rest/helpers/ionq/IonQServerHelper.cpp b/runtime/cudaq/platform/default/rest/helpers/ionq/IonQServerHelper.cpp index 6e88b0b28f..3d65a17a1a 100644 --- a/runtime/cudaq/platform/default/rest/helpers/ionq/IonQServerHelper.cpp +++ b/runtime/cudaq/platform/default/rest/helpers/ionq/IonQServerHelper.cpp @@ -220,6 +220,12 @@ bool IonQServerHelper::jobIsDone(ServerMessage &getJobResponse) { throw std::runtime_error( "ServerMessage doesn't contain 'status' key in the first job."); + // Throw a runtime error if the job has failed + if (jobs[0].at("status").get() == "failed") + throw std::runtime_error( + "The job failed upon submission. Check the job submission in your IonQ " + "account for more information."); + // Return whether the job is completed auto ret = jobs[0].at("status").get() == "completed"; return ret; From 78ea89b6a985f4c095e7ac5066276fd473b68eb7 Mon Sep 17 00:00:00 2001 From: "A.M. Santana" Date: Tue, 18 Jul 2023 17:33:48 +0000 Subject: [PATCH 2/2] remove return variable Signed-off-by: A.M. Santana --- .../platform/default/rest/helpers/ionq/IonQServerHelper.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/cudaq/platform/default/rest/helpers/ionq/IonQServerHelper.cpp b/runtime/cudaq/platform/default/rest/helpers/ionq/IonQServerHelper.cpp index 3d65a17a1a..5b5ca9f013 100644 --- a/runtime/cudaq/platform/default/rest/helpers/ionq/IonQServerHelper.cpp +++ b/runtime/cudaq/platform/default/rest/helpers/ionq/IonQServerHelper.cpp @@ -227,8 +227,7 @@ bool IonQServerHelper::jobIsDone(ServerMessage &getJobResponse) { "account for more information."); // Return whether the job is completed - auto ret = jobs[0].at("status").get() == "completed"; - return ret; + return jobs[0].at("status").get() == "completed"; } // Process the results from a job