@@ -13,6 +13,8 @@ import org.fathomnet.worms.etc.jdk.CustomExecutors
1313import org .fathomnet .worms .etc .jdk .CustomExecutors .*
1414import org .fathomnet .worms .etc .jdk .Logging .given
1515import org .fathomnet .worms .io .WormsLoader
16+
17+ import scala .util .control .NonFatal
1618// import org.fathomnet.worms.io.extended.CombineTrees.combine
1719import org .fathomnet .worms .io .extended .{CombineTrees , ExtendedLoader }
1820import picocli .CommandLine
@@ -129,13 +131,20 @@ object Main:
129131 val (wormsConcepts, rootOpt) = WormsLoader .load(wormsDir)
130132 val newRoot = rootOpt.map { root =>
131133 if (treeFiles.nonEmpty)
132- // Our new base. We use 0 as aphiaId so that the real aphiaIds are not incremented when the trees are combined
133- val newRoot = WormsNode (" object" , " " , 0L , 0L , Nil , Nil )
134- val newBranches = treeFiles.flatMap(ExtendedLoader .load(_)).toSeq
135- val trees = root +: newBranches
136- val combinedRoot = CombineTrees .combine(newRoot, trees, root.maxAphiaId)
137- // We need to reset the aphiaId to -1 so that it's obivious that the root is not a real aphiaId
138- combinedRoot.copy(aphiaId = - 1L )
134+ try {
135+ // Our new base. We use 0 as aphiaId so that the real aphiaIds are not incremented when the trees are combined
136+ val newRoot = WormsNode (" object" , " " , 0L , 0L , Nil , Nil )
137+ val newBranches = treeFiles.flatMap(ExtendedLoader .load).toSeq
138+ val trees = root +: newBranches
139+ val combinedRoot = CombineTrees .combine(newRoot, trees, root.maxAphiaId)
140+ // We need to reset the aphiaId to -1 so that it's obivious that the root is not a real aphiaId
141+ combinedRoot.copy(aphiaId = - 1L )
142+ }
143+ catch {
144+ case NonFatal (e) =>
145+ log.atWarn.withCause(e).log(" Error combining trees from " + treeFiles.mkString(" , " ))
146+ root
147+ }
139148 else root
140149 }
141150 (wormsConcepts, newRoot)
0 commit comments