|
@@ -122,6 +122,17 @@ let catch_exceptions ctx ?(final=(fun() -> ())) f p =
|
|
eval.caught_exception <- vnull;
|
|
eval.caught_exception <- vnull;
|
|
Option.may (build_exception_stack ctx) env;
|
|
Option.may (build_exception_stack ctx) env;
|
|
eval.env <- env;
|
|
eval.env <- env;
|
|
|
|
+
|
|
|
|
+ (* Careful: We have to get the message before resetting the context because toString() might access it. *)
|
|
|
|
+ let get_stack ctx =
|
|
|
|
+ let stack = match eval_stack with
|
|
|
|
+ | [] -> []
|
|
|
|
+ | l when p' = null_pos -> l (* If the exception position is null_pos, we're "probably" in a built-in function. *)
|
|
|
|
+ | _ :: l -> l (* Otherwise, ignore topmost frame position. *)
|
|
|
|
+ in
|
|
|
|
+ get_exc_error_stack ctx stack
|
|
|
|
+ in
|
|
|
|
+
|
|
if is v key_haxe_macro_Error then begin
|
|
if is v key_haxe_macro_Error then begin
|
|
let v1 = field v key_exception_message in
|
|
let v1 = field v key_exception_message in
|
|
let v2 = field v key_pos in
|
|
let v2 = field v key_pos in
|
|
@@ -139,7 +150,9 @@ let catch_exceptions ctx ?(final=(fun() -> ())) f p =
|
|
end else
|
|
end else
|
|
Error.raise_typing_error (Printf.sprintf "Unexpected value where haxe.macro.Error was expected: %s" (s_value 0 v).sstring) null_pos
|
|
Error.raise_typing_error (Printf.sprintf "Unexpected value where haxe.macro.Error was expected: %s" (s_value 0 v).sstring) null_pos
|
|
) (EvalArray.to_list sub)
|
|
) (EvalArray.to_list sub)
|
|
- | _ -> []
|
|
|
|
|
|
+ | _ ->
|
|
|
|
+ let stack = get_stack ctx in
|
|
|
|
+ List.map (fun p -> (Error.Custom "Called from here", p)) (List.rev stack)
|
|
in
|
|
in
|
|
reset_ctx();
|
|
reset_ctx();
|
|
final();
|
|
final();
|
|
@@ -168,13 +181,7 @@ let catch_exceptions ctx ?(final=(fun() -> ())) f p =
|
|
| v ->
|
|
| v ->
|
|
Error.raise_typing_error (Printf.sprintf "Invalid exception value where string was expected: %s" (s_value 0 v).sstring) null_pos
|
|
Error.raise_typing_error (Printf.sprintf "Invalid exception value where string was expected: %s" (s_value 0 v).sstring) null_pos
|
|
end else begin
|
|
end else begin
|
|
- (* Careful: We have to get the message before resetting the context because toString() might access it. *)
|
|
|
|
- let stack = match eval_stack with
|
|
|
|
- | [] -> []
|
|
|
|
- | l when p' = null_pos -> l (* If the exception position is null_pos, we're "probably" in a built-in function. *)
|
|
|
|
- | _ :: l -> l (* Otherwise, ignore topmost frame position. *)
|
|
|
|
- in
|
|
|
|
- let stack = get_exc_error_stack ctx stack in
|
|
|
|
|
|
+ let stack = get_stack ctx in
|
|
reset_ctx();
|
|
reset_ctx();
|
|
final();
|
|
final();
|
|
let p = if p' = null_pos then p else p' in
|
|
let p = if p' = null_pos then p else p' in
|