fix: wrap unpickle in try-catch
This commit is contained in:
18
src/Grid.fs
18
src/Grid.fs
@@ -622,8 +622,10 @@ type ExtendedGrid(grid: IGrid) =
|
||||
if IO.File.Exists fname then
|
||||
let pickle = IO.File.ReadAllBytes fname
|
||||
neighborIndex <-
|
||||
binarySerializer.UnPickle<NeighborIndex> pickle
|
||||
|> Some
|
||||
try binarySerializer.UnPickle<NeighborIndex> pickle |> Some
|
||||
with e ->
|
||||
Log.Error $"ExtendedGrid.loadNeighborIndex unpickle exception: {e.Message}:\n{e}"
|
||||
None
|
||||
true
|
||||
else
|
||||
false
|
||||
@@ -643,7 +645,11 @@ type ExtendedGrid(grid: IGrid) =
|
||||
let binarySerializer = FsPickler.CreateBinarySerializer()
|
||||
if IO.File.Exists fname then
|
||||
let pickle = IO.File.ReadAllBytes fname
|
||||
nodeTree <- binarySerializer.UnPickle<IdxTree> pickle |> Some
|
||||
nodeTree <-
|
||||
try binarySerializer.UnPickle<IdxTree> pickle |> Some
|
||||
with e ->
|
||||
Log.Error $"ExtendedGrid.loadNodeTree unpickle exception: {e.Message}:\n{e}"
|
||||
None
|
||||
true
|
||||
else
|
||||
false
|
||||
@@ -663,7 +669,11 @@ type ExtendedGrid(grid: IGrid) =
|
||||
let binarySerializer = FsPickler.CreateBinarySerializer()
|
||||
if IO.File.Exists fname then
|
||||
let pickle = IO.File.ReadAllBytes fname
|
||||
elementTree <- binarySerializer.UnPickle<IdxTree> pickle |> Some
|
||||
elementTree <-
|
||||
try binarySerializer.UnPickle<IdxTree> pickle |> Some
|
||||
with e ->
|
||||
Log.Error $"ExtendedGrid.loadElementTree unpickle exception: {e.Message}:\n{e}"
|
||||
None
|
||||
true
|
||||
else
|
||||
false
|
||||
Reference in New Issue
Block a user