Skip to content

Commit 6711ce8

Browse files
authored
Wrap file loading in try-catch (#1177)
1 parent 0ac0572 commit 6711ce8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/validators/validate-response-format.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ import buildMessage from 'ember-changeset-validations/utils/validation-errors';
44
import DraftNode from 'ember-osf-web/models/draft-node';
55
import File from 'ember-osf-web/models/file';
66
import NodeModel from 'ember-osf-web/models/node';
7+
import captureException from 'ember-osf-web/utils/capture-exception';
78

89
export function validateFileList(responseKey: string, node?: NodeModel | DraftNode): ValidatorFunction {
910
return async (_: string, newValue: File[]) => {
1011
if (newValue && node) {
1112
for (const file of newValue) {
1213
if (file && !file.isError) {
13-
// eslint-disable-next-line no-await-in-loop
14-
await file.reload();
14+
try {
15+
// validating these in sequence to prevent the files-burst throttling of API
16+
// eslint-disable-next-line no-await-in-loop
17+
await file.reload();
18+
} catch (e) {
19+
captureException(e);
20+
}
1521
}
1622
}
1723

0 commit comments

Comments
 (0)