Browse Source

guard against empty cif files

Alexander Rose 1 year ago
parent
commit
0a0ac7ee63
2 changed files with 2 additions and 0 deletions
  1. 1 0
      CHANGELOG.md
  2. 1 0
      src/mol-plugin-state/transforms/data.ts

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf
 
 - Fix return type of `State.tryGetCellData`
 - Don't change camera.target unless flyMode or pointerLock are enabled
+- Handle empty CIF files
 
 ## [v3.42.0] - 2023-11-05
 

+ 1 - 0
src/mol-plugin-state/transforms/data.ts

@@ -284,6 +284,7 @@ const ParseCif = PluginStateTransform.BuiltIn({
         return Task.create('Parse CIF', async ctx => {
             const parsed = await (typeof a.data === 'string' ? CIF.parse(a.data) : CIF.parseBinary(a.data)).runInContext(ctx);
             if (parsed.isError) throw new Error(parsed.message);
+            if (parsed.result.blocks.length === 0) return StateObject.Null;
             return new SO.Format.Cif(parsed.result);
         });
     }