diff options
author | Daniil Baturin <daniil@vyos.io> | 2023-07-21 12:08:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-21 12:08:25 +0100 |
commit | c5863024949344ceb0faad567bd77489f391d39c (patch) | |
tree | 1334ce9875bc85fb93dc7fd0cd927d33742b1675 /src | |
parent | cd4d75828efc51f42a53966ad7d85e4f0500b089 (diff) | |
parent | c0975ad35a05d6219be998a2d9855ddd89599df3 (diff) | |
download | vyos1x-config-c5863024949344ceb0faad567bd77489f391d39c.tar.gz vyos1x-config-c5863024949344ceb0faad567bd77489f391d39c.zip |
Merge pull request #18 from jestabro/catch-parse-error
T5385: catch correct errors in Xml_light Xml.parse_file
Diffstat (limited to 'src')
-rw-r--r-- | src/reference_tree.ml | 9 |
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 |