Skip to content

Commit

Permalink
Merge pull request #2677 from objectcomputing/bugfix-2676/mjml-templa…
Browse files Browse the repository at this point in the history
…te-errors

Get the full result from mjml2html so that we can catch the exception
  • Loading branch information
mkimberlin authored Oct 28, 2024
2 parents 0e22e64 + db65cb9 commit 10f478a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions web-ui/src/pages/EmailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,18 @@ const ComposeEmailStep = ({
const fileReader = new FileReader();
fileReader.onload = e => {
const mjmlContent = e.target.result.toString();
const { html } = mjml2html(mjmlContent);
onEmailContentsChange(html);
try {
const result = mjml2html(mjmlContent);
onEmailContentsChange(result.html);
} catch(e) {
window.snackDispatch({
type: UPDATE_TOAST,
payload: {
severity: 'error',
toast: e.message,
}
});
}
};

const file = event.target.files[0];
Expand Down

0 comments on commit 10f478a

Please sign in to comment.