2
0
Эх сурвалжийг харах

add message and pos to Fatal_error

Simon Krajewski 12 жил өмнө
parent
commit
e3d9fb9c46
4 өөрчлөгдсөн 8 нэмэгдсэн , 7 устгасан
  1. 1 1
      interp.ml
  2. 3 1
      main.ml
  3. 2 3
      typecore.ml
  4. 2 2
      typer.ml

+ 1 - 1
interp.ml

@@ -1630,7 +1630,7 @@ let std_lib =
 			VInt (((get_ctx()).curapi.get_com()).run_command (vstring cmd))
 		);
 		"sys_exit", Fun1 (fun code ->
-			if (get_ctx()).curapi.use_cache() then raise Typecore.Fatal_error;
+			if (get_ctx()).curapi.use_cache() then raise (Typecore.Fatal_error ("",Ast.null_pos));
 			exit (vint code);
 		);
 		"sys_exists", Fun1 (fun file ->

+ 3 - 1
main.ml

@@ -1303,8 +1303,10 @@ try
 		if r <> 0 then failwith ("Command failed with error " ^ string_of_int r)
 	) (List.rev !cmds)
 with
-	| Abort | Typecore.Fatal_error ->
+	| Abort ->
 		()
+	| Typecore.Fatal_error (m,p) ->
+		error ctx m p
 	| Common.Abort (m,p) ->
 		error ctx m p
 	| Lexer.Error (m,p) ->

+ 2 - 3
typecore.ml

@@ -126,7 +126,7 @@ type error_msg =
 	| Unknown_ident of string
 	| Stack of error_msg * error_msg
 
-exception Fatal_error
+exception Fatal_error of string * Ast.pos
 
 exception Forbid_package of (string * path * pos) * pos list * string
 
@@ -341,8 +341,7 @@ let exc_protect ctx f (where:string) =
 			f r
 		with
 			| Error (m,p) ->
-				display_error ctx (error_msg m) p;
-				raise Fatal_error
+				raise (Fatal_error ((error_msg m),p))
 	) in
 	r
 

+ 2 - 2
typer.ml

@@ -3155,7 +3155,7 @@ and build_call ctx acc el (with_type:with_type) p =
 			(* display additional info in the case the error is not part of our original call *)
 			if ep.pfile <> p.pfile || ep.pmax < p.pmin || ep.pmin > p.pmax then old ctx "Called from macro here" p
 		);
-		let e = try f() with Error (m,p) -> display_error ctx (error_msg m) p; ctx.on_error <- old; raise Fatal_error in
+		let e = try f() with Error (m,p) -> ctx.on_error <- old; raise (Fatal_error ((error_msg m),p)) in
 		ctx.on_error <- old;
 		e
 	| AKNo _ | AKSet _ | AKAccess _ ->
@@ -3667,7 +3667,7 @@ and flush_macro_context mint ctx =
 	end else mint in
 	(* we should maybe ensure that all filters in Main are applied. Not urgent atm *)
 	(try Interp.add_types mint types (Codegen.post_process [Codegen.Abstract.handle_abstract_casts mctx; Codegen.captured_vars mctx.com; Codegen.rename_local_vars mctx.com])
-	with Error (e,p) -> display_error ctx (error_msg e) p; raise Fatal_error);
+	with Error (e,p) -> raise (Fatal_error(error_msg e,p)));
 	Codegen.post_process_end()
 
 let create_macro_interp ctx mctx =