Skip to content

Commit

Permalink
[python] don't wrap classes that inherit from BaseException in _HxExc…
Browse files Browse the repository at this point in the history
…eption
  • Loading branch information
nadako committed Sep 28, 2014
1 parent d372af4 commit 8582bf9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion genpy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,19 @@ module Printer = struct
| TContinue ->
"continue"
| TThrow e1 ->
Printf.sprintf "raise _HxException(%s)" (print_expr pctx e1)
let rec is_native_exception t =
match Abstract.follow_with_abstracts t with
| TInst ({ cl_path = [],"BaseException" }, _) ->
true
| TInst ({ cl_super = Some csup }, _) ->
is_native_exception (TInst(fst csup, snd csup))
| _ ->
false
in
if is_native_exception e1.etype then
Printf.sprintf "raise %s" (print_expr pctx e1)
else
Printf.sprintf "raise _HxException(%s)" (print_expr pctx e1)
| TCast(e1,None) ->
print_expr pctx e1
| TMeta((Meta.Custom ":ternaryIf",_,_),{eexpr = TIf(econd,eif,Some eelse)}) ->
Expand Down

0 comments on commit 8582bf9

Please sign in to comment.