Browse Source

cellpack: fixed pdb fallback when opm fails

Alexander Rose 5 years ago
parent
commit
6fe83a9a70
2 changed files with 6 additions and 5 deletions
  1. 5 3
      src/extensions/cellpack/model.ts
  2. 1 2
      src/mol-util/data-source.ts

+ 5 - 3
src/extensions/cellpack/model.ts

@@ -68,11 +68,13 @@ async function getModel(plugin: PluginContext, id: string, ingredient: Ingredien
             }
         } else if (id.match(/^[1-9][a-zA-Z0-9]{3,3}$/i)) {
             if (surface){
-                const data = await getFromOPM(plugin, id, assetManager);
-                if (data.asset){
+                try {
+                    const data = await getFromOPM(plugin, id, assetManager);
                     assets.push(data.asset);
                     trajectory = await plugin.runTask(trajectoryFromPDB(data.pdb));
-                } else {
+                } catch (e) {
+                    // fallback to getFromPdb
+                    // console.error(e);
                     const { mmcif, asset } = await getFromPdb(plugin, id, assetManager);
                     assets.push(asset);
                     trajectory = await plugin.runTask(trajectoryFromMmCIF(mmcif));

+ 1 - 2
src/mol-util/data-source.ts

@@ -241,9 +241,8 @@ function processAjax<T extends DataType>(req: XMLHttpRequest, type: T): DataResp
         }
         throw new Error(`could not get requested response data '${type}'`);
     } else {
-        const status = req.statusText;
         RequestPool.deposit(req);
-        throw new Error(status);
+        throw new Error(`Download failed with status code ${req.status}`);
     }
 }