Skip to content

Commit e181944

Browse files
committed
easier debugging downstream on json strings
1 parent 4b8ca0d commit e181944

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/FileDFG/services/FileDFG.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,31 @@ function loadDFG!(dfgLoadInto::AbstractDFG, dst::AbstractString)
127127
varFiles = readdir(varFolder)
128128
factorFiles = readdir(factorFolder)
129129
@showprogress 1 "loading variables" for varFile in varFiles
130-
packedData = read("$varFolder/$varFile", String)
131-
packedData = JSON3.read(packedData, PackedVariable)
132-
push!(variables, unpackVariable(packedData))
130+
try
131+
jstr = read("$varFolder/$varFile", String)
132+
packedData = JSON3.read(jstr, PackedVariable)
133+
push!(variables, unpackVariable(packedData))
134+
catch ex
135+
@error("JSON3 is having trouble reading $varFolder/$varFile into a PackedVariable")
136+
@show jstr
137+
throw(ex)
138+
end
133139
end
134140
@info "Loaded $(length(variables)) variables - $(map(v->v.label, variables))"
135141
@info "Inserting variables into graph..."
136142
# Adding variables
137143
map(v->addVariable!(dfgLoadInto, v), variables)
138144

139145
@showprogress 1 "loading factors" for factorFile in factorFiles
140-
packedData = read("$factorFolder/$factorFile", String)
141-
packedData = JSON3.read(packedData, PackedFactor)
142-
push!(factors, unpackFactor(dfgLoadInto, packedData))
146+
try
147+
jstr = read("$factorFolder/$factorFile", String)
148+
packedData = JSON3.read(jstr, PackedFactor)
149+
push!(factors, unpackFactor(dfgLoadInto, packedData))
150+
catch ex
151+
@error("JSON3 is having trouble reading $factorFolder/$factorFile into a PackedFactor")
152+
@show jstr
153+
throw(ex)
154+
end
143155
end
144156
@info "Loaded $(length(variables)) factors - $(map(f->f.label, factors))"
145157
@info "Inserting factors into graph..."

0 commit comments

Comments
 (0)