Skip to content

Commit db65cb9

Browse files
committed
Get the full result from mjml2html so that we can catch the exception and present it to the user.
1 parent 0e22e64 commit db65cb9

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)