fix(upload): silence common client errors in sentry
This commit is contained in:
parent
30f3130e87
commit
10f6378cf0
1 changed files with 18 additions and 1 deletions
|
@ -4,6 +4,11 @@ import { z } from 'zod';
|
|||
|
||||
import { ApplicationController } from './application_controller';
|
||||
import { AutoUpload } from '../shared/activestorage/auto-upload';
|
||||
import {
|
||||
FileUploadError,
|
||||
FAILURE_CLIENT,
|
||||
ERROR_CODE_READ
|
||||
} from '../shared/activestorage/file-upload-error';
|
||||
|
||||
const Gon = z.object({ autosave: z.object({ debounce_delay: z.number() }) });
|
||||
|
||||
|
@ -95,7 +100,19 @@ export class AutosaveController extends ApplicationController {
|
|||
|
||||
private enqueueAutouploadRequest(target: HTMLInputElement, file: File) {
|
||||
const autoupload = new AutoUpload(target, file);
|
||||
try {
|
||||
autoupload.start();
|
||||
} catch (e) {
|
||||
const error = e as FileUploadError;
|
||||
// Report unexpected client errors to Sentry.
|
||||
// (But ignore usual client errors, or errors we can monitor better on the server side.)
|
||||
if (
|
||||
error.failureReason == FAILURE_CLIENT &&
|
||||
error.code != ERROR_CODE_READ
|
||||
) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a new autosave request to the queue.
|
||||
|
|
Loading…
Reference in a new issue