Explorar el Código

fixes #7141 : display proper error message while opening non utf-8 encoded files

i342302 hace 5 años
padre
commit
15717db736
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      packages/docregistry/src/context.ts

+ 3 - 2
packages/docregistry/src/context.ts

@@ -579,11 +579,12 @@ export class Context<T extends DocumentRegistry.IModel>
           return this._populate();
         }
       })
-      .catch(err => {
+      .catch(async err => {
         const localPath = this._manager.contents.localPath(this._path);
         const name = PathExt.basename(localPath);
+        const response = await err.response.json();
         if (err.message === 'Invalid response: 400 bad format') {
-          err = new Error('JupyterLab is unable to open this file type.');
+          err = new Error(response.message);
         }
         void this._handleError(err, `File Load Error for ${name}`);
         throw err;