Commits

Anonymous committed 64757ce

message cleanup

Comments (0)

Files changed (1)

ocamlspot/ocamlspot.ml

            but we still find a .cmi which is sym-linked to the original directory with .spot
         *)
         let cminame = body ^ ".cmi" in
-        let cmipath = find_in_path load_paths cminame in
-        let stat = Unix.lstat cmipath in
-        if stat.Unix.st_kind = Unix.S_LNK then begin
-          let cmipath = Filename.dirname cmipath ^/ Unix.readlink cmipath in
-          let spotpath = Filename.chop_extension cmipath ^ ext in
-          if Sys.file_exists spotpath then begin
-            Debug.format "Found an alternative %s: %s@." ext spotpath;
-	    spotpath 
+	try
+          let cmipath = find_in_path load_paths cminame in
+          let stat = Unix.lstat cmipath in
+          if stat.Unix.st_kind = Unix.S_LNK then begin
+            let cmipath = Filename.dirname cmipath ^/ Unix.readlink cmipath in
+            let spotpath = Filename.chop_extension cmipath ^ ext in
+            if Sys.file_exists spotpath then begin
+              Debug.format "Found an alternative %s: %s@." ext spotpath;
+	      spotpath 
+	    end else failwith (Printf.sprintf "spot file not found: %s, neither in %s" body_ext spotpath)
 	  end else raise Not_found
-        end else raise Not_found (* Sorry, no way to find the .spot *)
+	with
+	| (Failure _ as e) -> raise e
+	| _ -> failwith (Printf.sprintf "spot file not found: %s" body_ext)
         
 
       let load ~load_paths spotname : file =
         Debug.format "@[<2>spot searching %s in@ paths [@[%a@]]@]@." 
 	  spotname
-	  (Format.list "; " (fun ppf x -> Format.fprintf ppf "%S" x)) load_paths;
+	  (Format.list "; " (fun ppf x -> Format.fprintf ppf "%S" x)) 
+	  load_paths;
 	let body, ext = Filename.split_extension spotname in
         let path = find_in_path load_paths body ext in
         load_directly_with_cache path
 	  let spotname = Ident0.name ident ^ ".spot" in
           load ~load_paths spotname
 	with
-	| Not_found ->
+	| Failure s ->
 	    let spotname = Ident0.name ident ^ ".spit" in
-            load ~load_paths spotname
+            try
+	      load ~load_paths spotname
+	    with
+	    | Failure s' ->
+		(* CR jfuruse: ugly! *)
+		raise (Failure (s ^ "\n" ^ s'))
     end
 
     let to_env file = 
         Format.eprintf "BYE!@.";
 	exit 0
   with
+  | Failure s ->
+      Format.eprintf "Error: %s@." s;
+      exit 1
   | e ->
-      Format.eprintf "uncaught exception: %s" (Printexc.to_string e);
+      Format.eprintf "uncaught exception: %s@." (Printexc.to_string e);
       exit 1