jasmin
jasmin copied to clipboard
Handle non-existing input files
This also prints the “usage” help message; is this expected?
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.
Also, do not forget to rebase on top of a recent version of main
.
I don't understand why the CI is not happy!
I guess it’s an instance of #190.
But why it is a problem for this branch and not for main ?
This branch defines one new exception.
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
(* -------------------------------------------------------------------- *)
This issue should vanish once #227 is merged.