FSharp.Data Optional type exclusion

I have an Xml with one of the nodes as follows:

<code>23</code>

      

FSharp.Data correctly specifies the type "Code" as an int option. My problem is node is empty like this:

<code />

      

I am getting the following exception

Value is missing at <StartupCode$FSharp-Data>.$TextRuntime.GetNonOptionalValue@109-4.Invoke(String message) in C:\Git\FSharp.Data\src\CommonRuntime\TextRuntime.fs:line 109

      

Is there a way to return Option.None instead of throwing an exception?

EDIT: For types selected as parameter string, this works as expected.

+3


source to share





All Articles