jasmin icon indicating copy to clipboard operation
jasmin copied to clipboard

Handle non-existing input files

Open sarranz opened this issue 2 years ago • 2 comments

sarranz avatar Jul 28 '22 17:07 sarranz

This also prints the “usage” help message; is this expected?

vbgl avatar Jul 28 '22 19:07 vbgl

I think it could be a good idea, as the error might come from the user not actually pointing to a file that's not there but using an option incorrectly.

sarranz avatar Aug 02 '22 08:08 sarranz

Also, do not forget to rebase on top of a recent version of main.

vbgl avatar Aug 31 '22 08:08 vbgl

I don't understand why the CI is not happy!

bgregoir avatar Aug 31 '22 17:08 bgregoir

I guess it’s an instance of #190.

vbgl avatar Aug 31 '22 19:08 vbgl

But why it is a problem for this branch and not for main ?

bgregoir avatar Aug 31 '22 19:08 bgregoir

This branch defines one new exception.

vbgl avatar Sep 01 '22 05:09 vbgl

The following patches hides the problem again:

--- a/compiler/src/main_compiler.ml
+++ b/compiler/src/main_compiler.ml
@@ -4,14 +4,13 @@ open Glob_options

 (* -------------------------------------------------------------------- *)
 exception UsageError
-exception InputError of input_error

 let parse () =
   let error () = raise UsageError in
   let set_in s =
     if !infile <> "" then error();
-    if not (BatSys.file_exists s) then raise (InputError (FileNotFound s));
-    if BatSys.is_directory s then raise (InputError (FileIsDirectory s));
+    if not (BatSys.file_exists s) then raise (Invalid_argument (pp_input_error (FileNotFound s)));
+    if BatSys.is_directory s then raise (Invalid_argument (pp_input_error (FileIsDirectory s)));
     infile := s  in
   (* Set default option values *)
   if Arch.os = Some `Windows then set_cc "windows";
@@ -533,8 +532,8 @@ let main () =
     Arg.usage options usage_msg;
     exit 1

-  | InputError ie ->
-    Format.eprintf "Error: %s\n" (pp_input_error ie);
+  | Invalid_argument ie ->
+    Format.eprintf "Error: %s\n" ie;
     exit 1

 (* -------------------------------------------------------------------- *)

vbgl avatar Sep 01 '22 06:09 vbgl

This issue should vanish once #227 is merged.

vbgl avatar Sep 01 '22 08:09 vbgl