Selaa lähdekoodia

feat(exam): add protection when calling inspection/start during body position switch, prompt user for non-zero return codes

sw 1 kuukausi sitten
vanhempi
commit
adf50e8149
1 muutettua tiedostoa jossa 7 lisäystä ja 0 poistoa
  1. 7 0
      src/API/exam/changeBodyPosition.ts

+ 7 - 0
src/API/exam/changeBodyPosition.ts

@@ -4,5 +4,12 @@ export const changeBodyPosition = async (instanceUid: string) => {
   const response = await axiosInstance.post(`auth/task/inspection/start`, {
     instance_uid: instanceUid,
   });
+
+  if (response.data.code !== '0' && response.data.code !== '0x020101') {
+    throw new Error(
+      `Error code: ${response.data.code}, Description: ${response.data.description}`
+    );
+  }
+
   return response.data;
 };