Browse Source

[editor] Don't silence result related API errors

Johan Åhlén 4 years ago
parent
commit
d75ade5a27

+ 12 - 8
desktop/core/src/desktop/js/apps/editor/execution/api.ts

@@ -14,7 +14,7 @@
 // See the License for the specific language governing permissions and
 // See the License for the specific language governing permissions and
 // limitations under the License.
 // limitations under the License.
 
 
-import { extractErrorMessage, post, successResponseIsError } from 'api/utils';
+import { DefaultApiResponse, extractErrorMessage, post, successResponseIsError } from 'api/utils';
 import Executable, { ExecutableContext, ExecutionStatus } from 'apps/editor/execution/executable';
 import Executable, { ExecutableContext, ExecutionStatus } from 'apps/editor/execution/executable';
 import { ResultType } from 'apps/editor/execution/executionResult';
 import { ResultType } from 'apps/editor/execution/executionResult';
 
 
@@ -317,21 +317,25 @@ export const fetchResults = async (options: {
   rows: number;
   rows: number;
   startOver?: boolean;
   startOver?: boolean;
   silenceErrors?: boolean;
   silenceErrors?: boolean;
-}): Promise<ResultApiResponse> => {
+}): Promise<ResultApiResponse | undefined> => {
   const data = (await options.executable.toContext()) as FetchResultData;
   const data = (await options.executable.toContext()) as FetchResultData;
   data.rows = options.rows;
   data.rows = options.rows;
   data.startOver = options.startOver;
   data.startOver = options.startOver;
 
 
   // eslint-disable-next-line @typescript-eslint/ban-ts-comment
   // eslint-disable-next-line @typescript-eslint/ban-ts-comment
   // @ts-ignore
   // @ts-ignore
-  const transformResponse = (response: unknown) => JSON.bigdataParse(response).result;
+  const transformResponse = (response: unknown) => JSON.bigdataParse(response);
 
 
-  const responsePromise = post<ResultApiResponse>(FETCH_RESULT_DATA_API, data, {
-    silenceErrors: !!options.silenceErrors,
-    transformResponse
-  });
+  const response = await post<DefaultApiResponse & { result?: ResultApiResponse }>(
+    FETCH_RESULT_DATA_API,
+    data,
+    {
+      silenceErrors: !!options.silenceErrors,
+      transformResponse
+    }
+  );
 
 
-  return responsePromise;
+  return response.result;
 };
 };
 
 
 export const fetchResultSize = async (
 export const fetchResultSize = async (

+ 3 - 1
desktop/core/src/desktop/js/apps/editor/execution/executionResult.ts

@@ -155,7 +155,9 @@ export default class ExecutionResult {
       startOver: !!(options && options.startOver)
       startOver: !!(options && options.startOver)
     });
     });
 
 
-    this.handleResultResponse(resultResponse);
+    if (resultResponse) {
+      this.handleResultResponse(resultResponse);
+    }
   }
   }
 
 
   handleResultResponse(resultResponse: ResultApiResponse): void {
   handleResultResponse(resultResponse: ResultApiResponse): void {