Skip to content

Commit

Permalink
Backend/Marshalling: don't return null in ExtractType
Browse files Browse the repository at this point in the history
Second part of the fix for bug 242.
  • Loading branch information
knocte committed Jan 3, 2024
1 parent 50467e0 commit 852fcee
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/GWallet.Backend/Marshalling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,15 @@ module Marshalling =
let wrapper = JsonConvert.DeserializeObject<MarshallingWrapper<obj>> json
if Object.ReferenceEquals(wrapper, null) then
failwith <| SPrintF1 "Failed to extract type from JSON (null check): %s" json
try
Type.GetType wrapper.TypeName
with
| :? NullReferenceException as _nre ->
failwith <| SPrintF1 "Failed to extract type from JSON (NRE): %s" json
let res =
try
Type.GetType wrapper.TypeName
with
| :? NullReferenceException as _nre ->
failwith <| SPrintF2 "Failed to extract type '%s' from JSON (NRE): %s" wrapper.TypeName json
if isNull res then
failwith <| SPrintF2 "Failed to extract type '%s' from JSON (result was null): %s" wrapper.TypeName json
res

// FIXME: should we rather use JContainer.Parse? it seems JObject.Parse wouldn't detect error in this: {A:{"B": 1}}
// (for more info see replies of https://stackoverflow.com/questions/6903477/need-a-string-json-validator )
Expand Down

0 comments on commit 852fcee

Please sign in to comment.