mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-08 04:05:43 -05:00
main: print backtraces properly
This commit is contained in:
parent
668bd36311
commit
e6de1de949
1 changed files with 11 additions and 8 deletions
|
|
@ -151,22 +151,25 @@ let () = match main() with
|
||||||
exit 1
|
exit 1
|
||||||
| exception e ->
|
| exception e ->
|
||||||
let b = Printexc.get_backtrace () in
|
let b = Printexc.get_backtrace () in
|
||||||
|
let exit_ n =
|
||||||
|
if Printexc.backtrace_status () then (
|
||||||
|
Format.fprintf Format.std_formatter "%s@." b
|
||||||
|
);
|
||||||
|
Pervasives.exit n
|
||||||
|
in
|
||||||
begin match e with
|
begin match e with
|
||||||
| Error.Error msg ->
|
| Error.Error msg ->
|
||||||
Format.printf "@{<Red>Error@}: %s@." msg;
|
Format.printf "@{<Red>Error@}: %s@." msg;
|
||||||
ignore @@ exit 1
|
ignore @@ exit_ 1
|
||||||
| Out_of_time ->
|
| Out_of_time ->
|
||||||
Format.printf "Timeout@.";
|
Format.printf "Timeout@.";
|
||||||
exit 2
|
exit_ 2
|
||||||
| Out_of_space ->
|
| Out_of_space ->
|
||||||
Format.printf "Spaceout@.";
|
Format.printf "Spaceout@.";
|
||||||
exit 3
|
exit_ 3
|
||||||
| Invalid_argument e ->
|
| Invalid_argument e ->
|
||||||
Format.printf "invalid argument:\n%s@." e;
|
Format.printf "invalid argument:\n%s@." e;
|
||||||
exit 127
|
exit_ 127
|
||||||
| _ -> raise e
|
| _ -> raise e
|
||||||
end;
|
end
|
||||||
if Printexc.backtrace_status () then (
|
|
||||||
Format.fprintf Format.std_formatter "%s@." b
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue