Skip to content

Commit

Permalink
Merge pull request Netflix#3779 from Young-Zen/ui-fix-validation-erro…
Browse files Browse the repository at this point in the history
…r-handling

Fix validation error handling in workflow/task editor
  • Loading branch information
v1r3n authored and Young-Zen committed Nov 10, 2023
1 parent b421076 commit 2066bf9
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 2066bf9

Please sign in to comment.