javascript: ignore most common upload errors

This commit is contained in:
Pierre de La Morinerie 2020-05-13 16:15:29 +00:00
parent 4b288038d3
commit 86357b65f0

View file

@ -1,7 +1,10 @@
import Rails from '@rails/ujs'; import Rails from '@rails/ujs';
import AutoUploadController from './auto-upload-controller.js'; import AutoUploadController from './auto-upload-controller.js';
import { fire } from '@utils'; import { fire } from '@utils';
import { FAILURE_CONNECTIVITY } from '../../shared/activestorage/file-upload-error'; import {
FAILURE_CLIENT,
ERROR_CODE_READ
} from '../../shared/activestorage/file-upload-error';
// //
// DEBUG // DEBUG
@ -24,10 +27,11 @@ export default class AutoUploadsControllers {
try { try {
let controller = new AutoUploadController(input, file); let controller = new AutoUploadController(input, file);
await controller.start(); await controller.start();
} catch (error) { } catch (err) {
// Report errors to Sentry (except connectivity issues) // Report unexpected client errors to Sentry.
if (error.failureReason != FAILURE_CONNECTIVITY) { // (But ignore usual client errors, or errors we can monitor better on the server side.)
throw error; if (err.failureReason == FAILURE_CLIENT && err.code != ERROR_CODE_READ) {
throw err;
} }
} finally { } finally {
this._decrementInFlightUploads(form); this._decrementInFlightUploads(form);