15256: Fixes error handling when collection creation fails
authorEric Biagiotti <ebiagiotti@veritasgenetics.com>
Tue, 3 Dec 2019 15:38:32 +0000 (10:38 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Thu, 12 Dec 2019 16:07:18 +0000 (11:07 -0500)
Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti@veritasgenetics.com>

src/store/collections/collection-create-actions.ts

index 83b3e89c2b162e3f718f14005ea556c19eaf973c..39565f1d43b095c22470926e4f3d0f4d98f6c151 100644 (file)
@@ -42,7 +42,7 @@ export const openCollectionCreateDialog = (ownerUuid: string) =>
 export const createCollection = (data: CollectionCreateFormDialogData) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch(startSubmit(COLLECTION_CREATE_FORM_NAME));
-        let newCollection: CollectionResource;
+        let newCollection: CollectionResource | undefined;
         try {
             dispatch(progressIndicatorActions.START_WORKING(COLLECTION_CREATE_FORM_NAME));
             newCollection = await services.collectionService.create(data);
@@ -62,7 +62,7 @@ export const createCollection = (data: CollectionCreateFormDialogData) =>
                     hideDuration: 2000,
                     kind: SnackbarKind.ERROR
                 }));
-                await services.collectionService.delete(newCollection!.uuid);
+                if (newCollection) { await services.collectionService.delete(newCollection.uuid); }
             }
             return;
         } finally {