From d11e44dead53f9924fa9fb3fd591ca79ecdc382c Mon Sep 17 00:00:00 2001 From: Vincent Bernardoff Date: Fri, 21 Oct 2016 14:01:01 +0200 Subject: [PATCH] hex_decode: better error reporting --- src/utils/hex_encode.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/hex_encode.ml b/src/utils/hex_encode.ml index 65cf85f7f..3dc05256e 100644 --- a/src/utils/hex_encode.ml +++ b/src/utils/hex_encode.ml @@ -24,13 +24,14 @@ let hex_encode = gen_encode String.length (fun s i -> int_of_char s.[i]) (* From OCaml's stdlib. See [Digest.from_hex]. *) let gen_decode create set h = let n = String.length h in - if n mod 2 <> 0 then invalid_arg "hex_decode" ; + if n mod 2 <> 0 then invalid_arg ("hex_decode: " ^ h); let digit c = match c with | '0'..'9' -> int_of_char c - int_of_char '0' | 'A'..'F' -> int_of_char c - int_of_char 'A' + 10 | 'a'..'f' -> int_of_char c - int_of_char 'a' + 10 - | _c -> invalid_arg "hex_decode" in + | _c -> invalid_arg ("hex_decode: " ^ h) + in let byte i = digit h.[i] lsl 4 + digit h.[i+1] in let result = create (n / 2) in for i = 0 to n/2 - 1 do