Parcourir la source

Display help message in case of error reading rc file

Leo il y a 8 ans
Parent
commit
1610cb913d
1 fichiers modifiés avec 8 ajouts et 3 suppressions
  1. 8 3
      src/rc.ml

+ 8 - 3
src/rc.ml

@@ -118,9 +118,14 @@ let rec get_basic rc_name =
   match Sys.file_exists rc_name with
   match Sys.file_exists rc_name with
   | `No -> create_basic rc_name; get_basic rc_name
   | `No -> create_basic rc_name; get_basic rc_name
   | `Unknown -> failwith "Error reading configuration file";
   | `Unknown -> failwith "Error reading configuration file";
-  | `Yes ->  (* Try to read, if there is an error, reset file *)
-    Sexp.load_sexp rc_name
-    |> basic_rc_of_sexp
+  | `Yes -> try Sexp.load_sexp rc_name |> basic_rc_of_sexp
+    with exn ->
+      Messages.warning "Problem reading rc file";
+      sprintf
+        "Remove file '%s' to get a fresh rc file next time you call oclaunch"
+        rc_name
+      |> Messages.tips;
+      raise exn
 ;;
 ;;
 
 
 (* From objects to types *)
 (* From objects to types *)