Skip to content

Commit

Permalink
Preserve the inner exception of a TargetInvocationException
Browse files Browse the repository at this point in the history
  • Loading branch information
nakamura-to committed Oct 21, 2012
1 parent dc43266 commit cb98bd9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Soma.Core/Util.fs
Expand Up @@ -75,6 +75,11 @@ module Util =

module Reflection =

let rethrow ex =
let m = typeof<Exception>.GetMethod("PrepForRemoting", BindingFlags.NonPublic ||| BindingFlags.Instance)
m.Invoke(ex, [||]) |> ignore
raise ex

let getOptionInfo typ =
let cases = FSharpType.GetUnionCases(typ)
let none = FSharpType.GetUnionCases(typ).[0]
Expand Down Expand Up @@ -321,7 +326,10 @@ module Util =
let seq = m.Invoke(null, [| seq |])
let m = helperType.GetMethod("Invoke", BindingFlags.NonPublic ||| BindingFlags.Static)
let m = m.MakeGenericMethod (elementTyp)
m.Invoke(null, [| seq |])
try
m.Invoke(null, [| seq |])
with
| :? TargetInvocationException as e -> rethrow e.InnerException

let changeTypeFromSeqToList (elementTyp:Type) (seq:seq<obj>) =
changeTypeFromSeq seq elementTyp typeof<ToList>
Expand Down

0 comments on commit cb98bd9

Please sign in to comment.