Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3779 from Young-Zen/ui-fix-validation-error-handling
Browse files Browse the repository at this point in the history
Fix validation error handling in workflow/task editor
  • Loading branch information
v1r3n authored Sep 27, 2023
2 parents 4c14bb7 + a68016e commit 22ad050
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions ui/src/pages/definition/SaveTaskDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ export default function SaveTaskDialog({ onSuccess, onCancel, document }) {
},
onError: (err) => {
console.log("onerror", err);
let errStr = _.isString(err.body)
? err.body
: JSON.stringify(err.body, null, 2);
const errObj = JSON.parse(err);
let errStr = errObj.validationErrors && errObj.validationErrors.length > 0
? `${errObj.validationErrors[0].message}: ${errObj.validationErrors[0].path}`
: errObj.message;
setErrorMsg({
message: `${TASK_SAVE_FAILED}: ${errStr}`,
message: `${TASK_SAVE_FAILED} ${errStr}`,
dismissible: true,
});
},
Expand Down
9 changes: 5 additions & 4 deletions ui/src/pages/definition/SaveWorkflowDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ export default function SaveWorkflowDialog({ onSuccess, onCancel, document }) {
},
onError: (err) => {
console.log("onerror", err);
let errStr = _.isString(err.body)
? err.body
: JSON.stringify(err.body, null, 2);
setErrorMsg(`${WORKFLOW_SAVE_FAILED}: ${errStr}`);
const errObj = JSON.parse(err);
let errStr = errObj.validationErrors && errObj.validationErrors.length > 0
? `${errObj.validationErrors[0].message}: ${errObj.validationErrors[0].path}`
: errObj.message;
setErrorMsg(`${WORKFLOW_SAVE_FAILED} ${errStr}`);
},
});

Expand Down

0 comments on commit 22ad050

Please sign in to comment.