summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-07-20 15:51:54 -0500
committerJohn Estabrook <jestabro@vyos.io>2023-07-20 22:27:49 -0500
commitc0975ad35a05d6219be998a2d9855ddd89599df3 (patch)
tree1334ce9875bc85fb93dc7fd0cd927d33742b1675 /src
parentcd4d75828efc51f42a53966ad7d85e4f0500b089 (diff)
downloadvyos1x-config-c0975ad35a05d6219be998a2d9855ddd89599df3.tar.gz
vyos1x-config-c0975ad35a05d6219be998a2d9855ddd89599df3.zip
T5385: catch correct errors in Xml_light Xml.parse_file
Diffstat (limited to 'src')
-rw-r--r--src/reference_tree.ml9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/reference_tree.ml b/src/reference_tree.ml
index e47e9d8..302437e 100644
--- a/src/reference_tree.ml
+++ b/src/reference_tree.ml
@@ -194,14 +194,17 @@ let load_from_xml reftree file =
match xml with
| Xml.Element ("interfaceDefinition", _, children) ->
List.fold_left (insert_from_xml []) reftree children
- | _ -> raise (Bad_interface_definition "Should start with <interfaceDefinition>")
+ | _ -> raise (Bad_interface_definition "File should begin with <interfaceDefinition>")
in
try
let xml = Xml.parse_file file in
xml_to_reftree xml reftree
with
- | Xml.File_not_found msg -> raise (Bad_interface_definition msg)
- | Xml.Error e -> raise (Bad_interface_definition (Xml.error e))
+ | Xml_light_errors.File_not_found msg -> raise (Bad_interface_definition msg)
+ | Xml_light_errors.Xml_error err ->
+ let (msg, pos) = err in
+ let s = Printf.sprintf ": line %d in file %s" pos.eline file in
+ raise (Bad_interface_definition ((Xml.error_msg msg)^s))
let is_multi reftree path =
let data = Vytree.get_data reftree path in