From: Richard W.M. Jones Date: Fri, 28 Sep 2012 15:37:17 +0000 (+0100) Subject: Better error messages when parsing the init file (RHBZ#836231). X-Git-Tag: 1.0.8~6 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=11c3b2d5abdfe2e899ddb7e43c3485b7894704d0;p=virt-top.git Better error messages when parsing the init file (RHBZ#836231). --- diff --git a/virt-top/virt_top.ml b/virt-top/virt_top.ml index b304766..7e4677c 100644 --- a/virt-top/virt_top.ml +++ b/virt-top/virt_top.ml @@ -226,6 +226,24 @@ OPTIONS" in (* Read the init file. *) let try_to_read_init_file filename = let config = read_config_file filename in + (* Replacement functions that raise better errors when + * parsing the init file. + *) + let int_of_string s = + try int_of_string s + with Invalid_argument _ -> + failwithf (f_"%s: could not parse '%s' in init file: expecting an integer") + filename s in + let float_of_string s = + try float_of_string s + with Invalid_argument _ -> + failwithf (f_"%s: could not parse '%s' in init file: expecting a number") + filename s in + let bool_of_string s = + try bool_of_string s + with Invalid_argument _ -> + failwithf (f_"%s: could not parse '%s' in init file: expecting %s") + filename s "true|false" in List.iter ( function | _, "display", mode -> display_mode := display_of_cli mode