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

Commit

Permalink
Fix validation error handling in workflow/task editor
Browse files Browse the repository at this point in the history
Signed-off-by: yanghaojia <[email protected]>
  • Loading branch information
Young-Zen committed Sep 21, 2023
1 parent 8850219 commit 9efd256
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 9efd256

Please sign in to comment.