javascript: display a localized message on upload errors

This commit is contained in:
Pierre de La Morinerie 2019-10-24 14:03:48 +00:00
parent a3057afc22
commit bb024d1850

View file

@ -38,6 +38,15 @@ addUploadEventListener(PROGRESS_EVENT, ({ detail: { id, progress } }) => {
});
addUploadEventListener(ERROR_EVENT, event => {
// Display an error message
alert(
`Nous sommes désolés, une erreur sest produite lors de lenvoi du fichier.
(${event.detail.error})`
);
// Prevent ActiveStorage from displaying its own error message
event.preventDefault();
ProgressBar.error(event.detail.id, event.detail.error);
fire(document, 'sentry:capture-exception', new Error(event.detail.error));
});