exception handling - System.TypeInitializationException in a match constructor -


i trying discriminated union type string in f# (4.0, vs2015). code looks this:

type fooorbar =foo | bar let fooorbarfromstring str =     match str      | "foo" -> foo     | "bar" -> bar     | _ -> raise (system.argumentexception("invalid input")) 

the problem is, if default condition triggered, , exception raised, argument exception wrapped in system.typeinitializationexception. ex:

[<entrypoint>] let main argv =      let result = fooorbarfromstring "baz"  unhandled exception of type 'system.typeinitializationexception' occurred in project.exe 

further complicating things, vs2015 debugger chokes , shows "source not available". inspecting inner exception in locals view can see going on.

is there better way of setting errors in input data don't make debugging massive pain?


Comments

Popular posts from this blog

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -