Selaa lähdekoodia

properly catch errors that come from the TypePathHandler (closes #5669)

Simon Krajewski 9 vuotta sitten
vanhempi
commit
64366ea702
3 muutettua tiedostoa jossa 11 lisäystä ja 9 poistoa
  1. 1 1
      Makefile
  2. 2 3
      src/display/displayOutput.ml
  3. 8 5
      src/main.ml

+ 1 - 1
Makefile

@@ -147,7 +147,7 @@ src/display/display.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/context/meta.$(
 
 src/display/displayTypes.$(MODULE_EXT) : src/globals.$(MODULE_EXT) src/syntax/ast.$(MODULE_EXT)
 
-src/display/displayOutput.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/typing/error.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/typer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/display/display.$(MODULE_EXT)
+src/display/displayOutput.$(MODULE_EXT): src/globals.$(MODULE_EXT) src/typing/type.$(MODULE_EXT) src/typing/typer.$(MODULE_EXT) src/context/common.$(MODULE_EXT) src/display/display.$(MODULE_EXT)
 
 # generators
 

+ 2 - 3
src/display/displayOutput.ml

@@ -4,7 +4,6 @@ open Common.DisplayMode
 open Type
 open Display
 open Typecore
-open Error
 
 (* Old XML stuff *)
 
@@ -317,7 +316,7 @@ module TypePathHandler = struct
 	let complete_type_path com p =
 		let packs, modules = read_type_path com p in
 		if packs = [] && modules = [] then
-			(error ("No classes found in " ^ String.concat "." p) null_pos)
+			(abort ("No classes found in " ^ String.concat "." p) null_pos)
 		else
 			let packs = List.map (fun n -> n,Display.FKPackage,"") packs in
 			let modules = List.map (fun n -> n,Display.FKModule,"") modules in
@@ -375,7 +374,7 @@ module TypePathHandler = struct
 			in
 			Some fields
 		with _ ->
-			error ("Could not load module " ^ (s_type_path (p,c))) null_pos
+			abort ("Could not load module " ^ (s_type_path (p,c))) null_pos
 end
 
 (* New JSON stuff *)

+ 8 - 5
src/main.ml

@@ -909,11 +909,14 @@ with
 		raise (DisplayOutput.Completion (DisplayOutput.print_toplevel il))
 	| Parser.TypePath (p,c,is_import) ->
 		let fields =
-			match c with
-			| None ->
-				DisplayOutput.TypePathHandler.complete_type_path com p
-			| Some (c,cur_package) ->
-				DisplayOutput.TypePathHandler.complete_type_path_inner com p c cur_package is_import
+			try begin match c with
+				| None ->
+					DisplayOutput.TypePathHandler.complete_type_path com p
+				| Some (c,cur_package) ->
+					DisplayOutput.TypePathHandler.complete_type_path_inner com p c cur_package is_import
+			end with Common.Abort(msg,p) ->
+				error ctx msg p;
+				None
 		in
 		Option.may (fun fields -> raise (DisplayOutput.Completion (DisplayOutput.print_fields fields))) fields
 	| Display.ModuleSymbols s | Display.Diagnostics s | Display.Statistics s | Display.Metadata s ->