ソースを参照

Always catch failed file promise.

Krzysztof Krztoń 6 年 前
コミット
8838329768
1 ファイル変更9 行追加7 行削除
  1. 9 7
      packages/ckeditor5-upload/src/filerepository.js

+ 9 - 7
packages/ckeditor5-upload/src/filerepository.js

@@ -183,15 +183,17 @@ export default class FileRepository extends Plugin {
 
 		// Store also file => loader mapping so loader can be retrieved by file instance returned upon Promise resolution.
 		if ( fileOrPromise instanceof Promise ) {
-			loader.file
-				.then( file => {
-					this._loadersMap.set( file, loader );
-				} ).catch( () => {
-					// There was an error fetching file, so do not add anything to `this._loadersMap`.
-					// Also the error will be handled by `FileLoader` so no action is required here.
-				} );
+			loader.file.then( file => {
+				this._loadersMap.set( file, loader );
+			} );
 		}
 
+		// Catch the file promise rejection. If there are no `catch` closures, the browser
+		// will throw an error (see https://github.com/ckeditor/ckeditor5-upload/pull/90).
+		loader.file.catch( () => {
+			// The error will be handled by `FileLoader` so no action is required here.
+		} );
+
 		loader.on( 'change:uploaded', () => {
 			let aggregatedUploaded = 0;