Browse Source

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

i342302 5 years ago
parent
commit
15717db736
1 changed files with 3 additions and 2 deletions
  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;