diff options
author | Gabriel Scherer <gabriel.scherer@gmail.com> | 2022-11-26 00:58:27 +0100 |
---|---|---|
committer | Gabriel Scherer <gabriel.scherer@gmail.com> | 2022-11-26 01:02:42 +0100 |
commit | d14ec1a91d6b618f115c392c29e1203a5f4bbaea (patch) | |
tree | 36cec3890dada7b5b6a2be18b00a66f884c7f8f5 /toplevel/topdirs.ml | |
parent | 3abbbd4f9cfb426526388513099c5edbdb636a42 (diff) | |
download | ocaml-d14ec1a91d6b618f115c392c29e1203a5f4bbaea.tar.gz |
[minor] topdirs.ml: bound the scope of find_printer exception handling
Diffstat (limited to 'toplevel/topdirs.ml')
-rw-r--r-- | toplevel/topdirs.ml | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/toplevel/topdirs.ml b/toplevel/topdirs.ml index e6e88d7057..bbf29b3b8a 100644 --- a/toplevel/topdirs.ml +++ b/toplevel/topdirs.ml @@ -291,8 +291,9 @@ let find_printer ppf lid = raise Exit let dir_install_printer ppf lid = - try - let (path, kind) = find_printer ppf lid in + match find_printer ppf lid with + | exception Exit -> () + | (path, kind) -> let v = eval_value_path !toplevel_env path in match kind with | Printer.Old ty_arg -> @@ -310,17 +311,16 @@ let dir_install_printer ppf lid = Succ (fun fn -> build ((Obj.obj v : _ -> Obj.t) fn) args) in install_generic_printer' path ty_path (build v printer_args_ty) - with Exit -> () let dir_remove_printer ppf lid = - try - let (path, _kind) = find_printer ppf lid in + match find_printer ppf lid with + | exception Exit -> () + | (path, _kind) -> begin try remove_printer path with Not_found -> fprintf ppf "No printer named %a.@." Printtyp.longident lid end - with Exit -> () let _ = add_directive "install_printer" (Directive_ident (with_error_fmt dir_install_printer)) |