Skip to content

Commit 06aed4c

Browse files
committed
A first try at throwing an error
1 parent 65c1c20 commit 06aed4c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/blueapi/blueapi.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,16 @@ export function submitPlan(
7474
name: planName,
7575
params: planParams,
7676
})
77-
.then((res) => res.json().then((res) => res["task_id"]))
78-
.catch((error) => console.log(error));
77+
.then((res) => {
78+
if (!res.ok) {
79+
throw new Error(
80+
`Unable to POST request,response error ${res.statusText}`
81+
);
82+
}
83+
res.json();
84+
})
85+
.then((res) => res["task_id"]); // This probably needs to be done separately or something
86+
// .catch((error) => console.log(error));
7987
}
8088

8189
export function submitAndRunPlanImmediately(

0 commit comments

Comments
 (0)