Define server error messages to display in FE from the server (#12973)
Currently, when a server query or mutation from the front-end fails, the error message defined server-side is displayed in a snackbar in the front-end. These error messages usually contain technical details that don't belong to the user interface, such as "ObjectMetadataCollection not found" or "invalid ENUM value for ...". **BE** In addition to the original error message that is still needed (for the request response, debugging, sentry monitoring etc.), we add a `displayedErrorMessage` that will be used in the snackbars. It's only relevant to add it for the messages that will reach the FE (ie. not in jobs or in rest api for instance) and if it can help the user sort out / fix things (ie. we do add displayedErrorMessage for "Cannot create multiple draft versions for the same workflow" or "Cannot delete [field], please update the label identifier field first", but not "Object metadata does not exist"), even if in practice in the FE users should not be able to perform an action that will not work (ie should not be able to save creation of multiple draft versions of the same workflows). **FE** To ease the usage we replaced enqueueSnackBar with enqueueErrorSnackBar and enqueueSuccessSnackBar with an api that only requires to pass on the error. If no displayedErrorMessage is specified then the default error message is `An error occured.`
This commit is contained in:
+5
@@ -1,3 +1,5 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
|
||||
import {
|
||||
WorkflowQueryValidationException,
|
||||
WorkflowQueryValidationExceptionCode,
|
||||
@@ -11,6 +13,9 @@ export const assertWorkflowStatusesNotSet = (
|
||||
throw new WorkflowQueryValidationException(
|
||||
'Statuses cannot be set manually.',
|
||||
WorkflowQueryValidationExceptionCode.FORBIDDEN,
|
||||
{
|
||||
userFriendlyMessage: t`Statuses cannot be set manually.`,
|
||||
},
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
+5
@@ -1,3 +1,5 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
|
||||
import { WorkflowVersionWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-version.workspace-entity';
|
||||
import { WorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
|
||||
import {
|
||||
@@ -14,6 +16,9 @@ export function assertWorkflowVersionHasSteps(
|
||||
throw new WorkflowTriggerException(
|
||||
'Workflow version does not contain at least one step',
|
||||
WorkflowTriggerExceptionCode.INVALID_WORKFLOW_VERSION,
|
||||
{
|
||||
userFriendlyMessage: t`Workflow version does not contain at least one step`,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -1,3 +1,5 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
|
||||
import {
|
||||
WorkflowQueryValidationException,
|
||||
WorkflowQueryValidationExceptionCode,
|
||||
@@ -14,6 +16,9 @@ export const assertWorkflowVersionIsDraft = (
|
||||
throw new WorkflowQueryValidationException(
|
||||
'Workflow version is not in draft status',
|
||||
WorkflowQueryValidationExceptionCode.FORBIDDEN,
|
||||
{
|
||||
userFriendlyMessage: t`Workflow version is not in draft status`,
|
||||
},
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
+5
@@ -1,3 +1,5 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
|
||||
import { WorkflowVersionWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-version.workspace-entity';
|
||||
import {
|
||||
WorkflowTriggerException,
|
||||
@@ -17,6 +19,9 @@ export function assertWorkflowVersionTriggerIsDefined(
|
||||
throw new WorkflowTriggerException(
|
||||
'Workflow version does not contain trigger',
|
||||
WorkflowTriggerExceptionCode.INVALID_WORKFLOW_VERSION,
|
||||
{
|
||||
userFriendlyMessage: t`Workflow version does not contain trigger`,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user