Sure, compare the output of the following. Here is a command defined with Command.basic
:
let command_basic =
Command.basic ~summary:"This command is defined using [Command.basic]."
(let%map_open.Command () = return () in
fun () -> failwith "Raising an exception.")
Uncaught exception:
(Failure "Raising an exception.")
Raised at Stdlib.failwith in file "stdlib.ml", line 29, characters 17-33
Called from Core_kernel__Command.For_unix.run.(fun) in file "src/command.ml", line 2453, characters 8-238
Called from Base__Exn.handle_uncaught_aux in file "src/exn.ml", line 111, characters 6-10
And here is a command defined with basic2
:
let command_basic2 =
basic2 ~summary:"This command is defined using [basic2]."
(let%map_open.Command () = return () in
failwith "Raising an exception.")
Error parsing command line:
(Failure "Raising an exception.")
For usage information, run
main.exe basic2 -help
Notice how in the latter case, even though we raised an exception in what was meant to be the body of our command, the exception was presented to the user as a parsing error.