@@ -43,9 +43,17 @@ function _packFactor(dfg::G, f::DFGFactor)::Dict{String, Any} where G <: Abstrac
43
43
props[" tags" ] = JSON2. write (f. tags)
44
44
# Pack the node data
45
45
fnctype = f. data. fnc. usrfnc!
46
- packtype = getfield (_getmodule (fnctype), Symbol (" Packed$(_getname (fnctype)) " ))
47
- packed = convert (PackedFunctionNodeData{packtype}, f. data)
48
- props[" data" ] = JSON2. write (packed)
46
+ try
47
+ packtype = getfield (_getmodule (fnctype), Symbol (" Packed$(_getname (fnctype)) " ))
48
+ packed = convert (PackedFunctionNodeData{packtype}, f. data)
49
+ props[" data" ] = JSON2. write (packed)
50
+ catch ex
51
+ io = IOBuffer ()
52
+ showerror (io, ex, catch_backtrace ())
53
+ err = String (take! (io))
54
+ msg = " Error while packing '$(f. label) ' as '$fnctype ', please check the unpacking/packing converters for this factor - \r\n $err "
55
+ error (msg)
56
+ end
49
57
# Include the type
50
58
props[" fnctype" ] = String (_getname (fnctype))
51
59
props[" _variableOrderSymbols" ] = JSON2. write (f. _variableOrderSymbols)
@@ -61,11 +69,21 @@ function _unpackFactor(dfg::G, packedProps::Dict{String, Any}, iifModule)::DFGFa
61
69
tags = JSON2. read (packedProps[" tags" ], Vector{Symbol})
62
70
63
71
data = packedProps[" data" ]
72
+ @debug " Decoding $label ..."
64
73
datatype = packedProps[" fnctype" ]
65
74
packtype = getfield (Main, Symbol (" Packed" * datatype))
66
- packed = JSON2. read (data, GenericFunctionNodeData{packtype,String})
67
- fullFactor = iifModule. decodePackedType (dfg, packed)
68
- # fullFactor = dfg.decodePackedTypeFunc(dfg, packed)
75
+ packed = nothing
76
+ fullFactor = nothing
77
+ try
78
+ packed = JSON2. read (data, GenericFunctionNodeData{packtype,String})
79
+ fullFactor = iifModule. decodePackedType (dfg, packed)
80
+ catch ex
81
+ io = IOBuffer ()
82
+ showerror (io, ex, catch_backtrace ())
83
+ err = String (take! (io))
84
+ msg = " Error while unpacking '$label ' as '$datatype ', please check the unpacking/packing converters for this factor - \r\n $err "
85
+ error (msg)
86
+ end
69
87
70
88
# Include the type
71
89
_variableOrderSymbols = JSON2. read (packedProps[" _variableOrderSymbols" ], Vector{Symbol})
0 commit comments