19691: Improves error message reporting.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 9 Dec 2022 20:51:48 +0000 (21:51 +0100)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 9 Dec 2022 20:51:48 +0000 (21:51 +0100)
Also, adds unknown error message handling to project update dialog.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

src/store/collections/collection-create-actions.ts
src/store/collections/collection-update-actions.ts
src/store/projects/project-create-actions.ts
src/store/projects/project-update-actions.ts

index 939ae9f984604ed05b80bd28fe5be39b245b678f..f3d1fd3b77ebcc71df07e169f8dfdc4c79b1d36a 100644 (file)
@@ -71,8 +71,11 @@ export const createCollection = (data: CollectionCreateFormDialogData) =>
             } else {
                 dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME));
                 dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_CREATE_FORM_NAME }));
+                const errMsg = e.errors
+                    ? e.errors.join('')
+                    : 'There was an error while creating the collection';
                 dispatch(snackbarActions.OPEN_SNACKBAR({
-                    message: e.errors.join(''),
+                    message: errMsg,
                     hideDuration: 2000,
                     kind: SnackbarKind.ERROR
                 }));
index 2e66ce2caea1710cf77359040bb1143ca2ab1b82..d955c9478d3d6d3198a2a249e94a142cd8c5a77a 100644 (file)
@@ -72,8 +72,11 @@ export const updateCollection = (collection: CollectionUpdateFormDialogData) =>
                 dispatch(stopSubmit(COLLECTION_UPDATE_FORM_NAME, { name: 'Collection with the same name already exists.' } as FormErrors));
             } else {
                 dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_UPDATE_FORM_NAME }));
+                const errMsg = e.errors
+                    ? e.errors.join('')
+                    : 'There was an error while updating the collection';
                 dispatch(snackbarActions.OPEN_SNACKBAR({
-                    message: e.errors.join(''),
+                    message: errMsg,
                     hideDuration: 2000,
                     kind: SnackbarKind.ERROR }));
                 }
index e70ff0f69a9c16743bcea2548c6301d59326e87c..c15c37483ed88e9444618ae4ef13cebf5cb91b67 100644 (file)
@@ -79,8 +79,11 @@ export const createProject = (project: Partial<ProjectResource>) =>
             } else {
                 dispatch(stopSubmit(PROJECT_CREATE_FORM_NAME));
                 dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_CREATE_FORM_NAME }));
+                const errMsg = e.errors
+                    ? e.errors.join('')
+                    : 'There was an error while creating the collection';
                 dispatch(snackbarActions.OPEN_SNACKBAR({
-                    message: e.errors.join(''),
+                    message: errMsg,
                     hideDuration: 2000,
                     kind: SnackbarKind.ERROR
                 }));
index a9255e293282fb1c1e46863bdb6ad9a06f8611a5..057c7cfac59794b95dc7259b66c965551df5c28e 100644 (file)
@@ -24,6 +24,7 @@ import { Participant } from "views-components/sharing-dialog/participant-select"
 import { ProjectProperties } from "./project-create-actions";
 import { getResource } from "store/resources/resources";
 import { ProjectResource } from "models/project";
+import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions";
 
 export interface ProjectUpdateFormDialogData {
     uuid: string;
@@ -71,7 +72,16 @@ export const updateProject = (project: ProjectUpdateFormDialogData) =>
             const error = getCommonResourceServiceError(e);
             if (error === CommonResourceServiceError.UNIQUE_NAME_VIOLATION) {
                 dispatch(stopSubmit(PROJECT_UPDATE_FORM_NAME, { name: 'Project with the same name already exists.' } as FormErrors));
+            } else {
+                dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_UPDATE_FORM_NAME }));
+                const errMsg = e.errors
+                    ? e.errors.join('')
+                    : 'There was an error while updating the project';
+                dispatch(snackbarActions.OPEN_SNACKBAR({
+                    message: errMsg,
+                    hideDuration: 2000,
+                    kind: SnackbarKind.ERROR }));
             }
-            return ;
+            return;
         }
     };