From 7922eba882d6f30c062386bbfc4fb47293d7aa03 Mon Sep 17 00:00:00 2001 From: Virgile Prevosto <virgile.prevosto@m4x.org> Date: Wed, 15 Feb 2023 17:02:13 +0100 Subject: [PATCH] [File] Ensures a rogue external parser won't lead to confusing error msg --- src/kernel_services/ast_queries/file.ml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/kernel_services/ast_queries/file.ml b/src/kernel_services/ast_queries/file.ml index 379b8bf9935..b15088fa8d6 100644 --- a/src/kernel_services/ast_queries/file.ml +++ b/src/kernel_services/ast_queries/file.ml @@ -606,14 +606,14 @@ let parse_cabs cpp_command = function if not (Sys.file_exists (f:>string)) then Kernel.abort "file %a does not exist." Filepath.Normalized.pretty f; - try - Kernel.feedback "Parsing %a (external front-end)" - Datatype.Filepath.pretty f; - Hashtbl.find check_suffixes suf (f:>string) - with Not_found -> - Kernel.abort - "could not find a suitable plugin for parsing %a." - Filepath.Normalized.pretty f + Kernel.feedback "Parsing %a (external front-end)" + Datatype.Filepath.pretty f; + (match Hashtbl.find_opt check_suffixes suf with + | Some parse -> parse (f:>string) + | None -> + Kernel.abort + "could not find a suitable plugin for parsing %a." + Filepath.Normalized.pretty f) let to_cil_cabs cpp_cmds_and_args f = try -- GitLab