Procházet zdrojové kódy

don't spoil the latest exception stack trace on `is_debug_run()`

Aleksandr Kuzmenko před 6 roky
rodič
revize
5c85701dce
2 změnil soubory, kde provedl 4 přidání a 5 odebrání
  1. 2 2
      src/compiler/main.ml
  2. 2 3
      src/compiler/server.ml

+ 2 - 2
src/compiler/main.ml

@@ -1076,7 +1076,7 @@ with
 		error ctx m p
 	| Arg.Bad msg ->
 		error ctx ("Error: " ^ msg) null_pos
-	| Failure msg when not (is_debug_run()) ->
+	| Failure msg when not is_debug_run ->
 		error ctx ("Error: " ^ msg) null_pos
 	| HelpMessage msg ->
 		com.info msg null_pos
@@ -1185,7 +1185,7 @@ with
 		raise exc
 	| Out_of_memory as exc ->
 		raise exc
-	| e when (try Sys.getenv "OCAMLRUNPARAM" <> "b" || CompilationServer.runs() with _ -> true) && not (is_debug_run()) ->
+	| e when (try Sys.getenv "OCAMLRUNPARAM" <> "b" || CompilationServer.runs() with _ -> true) && not is_debug_run ->
 		error ctx (Printexc.to_string e) null_pos
 
 ;;

+ 2 - 3
src/compiler/server.ml

@@ -16,8 +16,7 @@ let measure_times = ref false
 let prompt = ref false
 let start_time = ref (Timer.get_time())
 
-let is_debug_run() =
-	try Sys.getenv "HAXEDEBUG" = "1" with _ -> false
+let is_debug_run = try Sys.getenv "HAXEDEBUG" = "1" with _ -> false
 
 type context = {
 	com : Common.context;
@@ -614,7 +613,7 @@ let wait_loop process_params verbose accept =
 			let estr = Printexc.to_string e in
 			ServerMessage.uncaught_error estr;
 			(try write ("\x02\n" ^ estr); with _ -> ());
-			if is_debug_run() then print_endline (estr ^ "\n" ^ Printexc.get_backtrace());
+			if is_debug_run then print_endline (estr ^ "\n" ^ Printexc.get_backtrace());
 			if e = Out_of_memory then begin
 				close();
 				exit (-1);