Explorar el Código

Add catch block for failed file promise in `FileRepository`.

Krzysztof Krztoń hace 7 años
padre
commit
69bf698a13
Se han modificado 1 ficheros con 7 adiciones y 3 borrados
  1. 7 3
      packages/ckeditor5-upload/src/filerepository.js

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

@@ -183,9 +183,13 @@ 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 );
-			} );
+			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.on( 'change:uploaded', () => {