Skip to content
Snippets Groups Projects
Commit 7b794ad9 authored by Michele Alberti's avatar Michele Alberti
Browse files

Register custom printers for the used exceptions in order to display clean error messages.

parent 8703afd4
No related branches found
No related tags found
No related merge requests found
...@@ -215,6 +215,15 @@ let default_info = ...@@ -215,6 +215,15 @@ let default_info =
let default_cmd = Term.(ret (const (fun _ -> `Help (`Pager, None)) $ const ())) let default_cmd = Term.(ret (const (fun _ -> `Help (`Pager, None)) $ const ()))
let () =
(* We register custom printers for a selection of exceptions otherwise Why3
will print the related messages as "anomaly: <exception with message>". *)
Why3.Exn_printer.register (fun fmt exn ->
match exn with
| Invalid_argument msg -> Fmt.pf fmt "Invalid argument: %s" msg
| Failure msg -> Fmt.pf fmt "Failure: %s" msg
| _ -> raise exn)
let () = let () =
try try
Cmd.group ~default:default_cmd default_info [ config_cmd; verify_cmd ] Cmd.group ~default:default_cmd default_info [ config_cmd; verify_cmd ]
......
...@@ -77,7 +77,7 @@ let answer_saver limit config task env prover dataset_csv = ...@@ -77,7 +77,7 @@ let answer_saver limit config task env prover dataset_csv =
let handle_task_saver task env dataset_csv command = let handle_task_saver task env dataset_csv command =
let dataset_filename = let dataset_filename =
match dataset_csv with match dataset_csv with
| None -> failwith "Error, no dataset provided for SAVer." | None -> invalid_arg "No dataset provided for SAVer"
| Some s -> s | Some s -> s
in in
let goal = Task.task_goal_fmla task in let goal = Task.task_goal_fmla task in
...@@ -104,13 +104,14 @@ let answer_saver limit config task env prover dataset_csv = ...@@ -104,13 +104,14 @@ let answer_saver limit config task env prover dataset_csv =
let svm_filename = let svm_filename =
match Language.lookup_loaded_svms svm_app_sym with match Language.lookup_loaded_svms svm_app_sym with
| Some t -> t.filename | Some t -> t.filename
| None -> failwith "SVM file not found in environment." | None -> invalid_arg "No SVM model found in task"
in in
(eps, svm_filename) (eps, svm_filename)
else failwith "Wrong predicate found." else failwith "Wrong predicate found"
(* no other predicate than robust_to is supported *) | _ ->
| _ -> failwith "Unsupported by SAVer.") (* no other predicate than robust_to is supported *)
| _ -> failwith "Unsupported by SAVer." failwith "Unsupported predicate by SAVer")
| _ -> failwith "Unsupported predicate by SAVer"
in in
let svm_file = Unix.realpath svm_filename in let svm_file = Unix.realpath svm_filename in
let dataset_file = Unix.realpath dataset_filename in let dataset_file = Unix.realpath dataset_filename in
...@@ -175,7 +176,7 @@ let answer_generic limit config task driver (prover : Whyconf.config_prover) = ...@@ -175,7 +176,7 @@ let answer_generic limit config task driver (prover : Whyconf.config_prover) =
match Task.on_meta_excl Native_nn_prover.meta_nn_filename task_prepared with match Task.on_meta_excl Native_nn_prover.meta_nn_filename task_prepared with
| Some [ MAstr nn_file ] -> nn_file | Some [ MAstr nn_file ] -> nn_file
| Some _ -> assert false (* By construction of the meta. *) | Some _ -> assert false (* By construction of the meta. *)
| None -> invalid_arg (Fmt.str "No neural network model found in task") | None -> invalid_arg "No neural network model found in task"
in in
let nn_file = Unix.realpath nn_file in let nn_file = Unix.realpath nn_file in
let command = Re__Core.replace_string nnet_or_onnx ~by:nn_file command in let command = Re__Core.replace_string nnet_or_onnx ~by:nn_file command in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment