From 6fe83a9a7059c939c4fa077ec2a3d05ae74514c0 Mon Sep 17 00:00:00 2001
From: Alexander Rose <alexander.rose@weirdbyte.de>
Date: Sun, 26 Apr 2020 12:27:30 -0700
Subject: [PATCH] cellpack: fixed pdb fallback when opm fails

---
 src/extensions/cellpack/model.ts | 8 +++++---
 src/mol-util/data-source.ts      | 3 +--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/extensions/cellpack/model.ts b/src/extensions/cellpack/model.ts
index 3378fa77a..9344fed2a 100644
--- a/src/extensions/cellpack/model.ts
+++ b/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));
diff --git a/src/mol-util/data-source.ts b/src/mol-util/data-source.ts
index 1ff444020..609d1a9d5 100644
--- a/src/mol-util/data-source.ts
+++ b/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}`);
     }
 }
 
-- 
GitLab