Skip to content

Commit 10f478a

Browse files
authored
Merge pull request #2677 from objectcomputing/bugfix-2676/mjml-template-errors
Get the full result from mjml2html so that we can catch the exception
2 parents 0e22e64 + db65cb9 commit 10f478a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

web-ui/src/pages/EmailPage.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,18 @@ const ComposeEmailStep = ({
185185
const fileReader = new FileReader();
186186
fileReader.onload = e => {
187187
const mjmlContent = e.target.result.toString();
188-
const { html } = mjml2html(mjmlContent);
189-
onEmailContentsChange(html);
188+
try {
189+
const result = mjml2html(mjmlContent);
190+
onEmailContentsChange(result.html);
191+
} catch(e) {
192+
window.snackDispatch({
193+
type: UPDATE_TOAST,
194+
payload: {
195+
severity: 'error',
196+
toast: e.message,
197+
}
198+
});
199+
}
190200
};
191201

192202
const file = event.target.files[0];

0 commit comments

Comments
 (0)