Skip to content

Commit

Permalink
Merge pull request #268 from adobecom/dash-error-handling
Browse files Browse the repository at this point in the history
[MWPW-160156] Stop and show error toast on API failure
  • Loading branch information
qiyundai authored Oct 24, 2024
2 parents ffda0d0 + 22287f6 commit 14a53a5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ecc/blocks/ecc-dashboard/ecc-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ function initMoreOptions(props, config, eventObj, row) {
toolBox.remove();
row.classList.add('pending');
const newEventJSON = await createEvent(cloneFilter(payload));

if (newEventJSON.error) {
row.classList.remove('pending');
showToast(props, newEventJSON.error, { variant: 'negative' });
return;
}

const newJson = await getEvents();
props.data = newJson.events;
props.filteredData = newJson.events;
Expand Down Expand Up @@ -345,7 +352,14 @@ function initMoreOptions(props, config, eventObj, row) {
underlay.open = false;
dialog.innerHTML = '';
row.classList.add('pending');
await deleteEvent(eventObj.eventId);
const resp = await deleteEvent(eventObj.eventId);

if (resp.error) {
row.classList.remove('pending');
showToast(props, resp.error, { variant: 'negative' });
return;
}

const newJson = await getEvents();
props.data = newJson.events;
props.filteredData = newJson.events;
Expand Down

0 comments on commit 14a53a5

Please sign in to comment.