From b461b6c0c67bfdd23b8b623ac53ebb99ec71c921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Sun, 26 Feb 2017 01:25:47 +0100 Subject: [PATCH] Shell: protection against serialisation error. --- src/node/db/store_helpers.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/node/db/store_helpers.ml b/src/node/db/store_helpers.ml index 2e56a6d6d..c0699789a 100644 --- a/src/node/db/store_helpers.ml +++ b/src/node/db/store_helpers.ml @@ -15,7 +15,12 @@ module Make_value (V : ENCODED_VALUE) = struct match Data_encoding.Binary.of_bytes V.encoding b with | None -> generic_error "Cannot parse data" (* TODO personalize *) | Some v -> ok v - let to_bytes = Data_encoding.Binary.to_bytes V.encoding + let to_bytes v = + try Data_encoding.Binary.to_bytes V.encoding v + with exn -> + Logging.Node.State.log_error + "Exception while serializing value %a" pp_exn exn ; + MBytes.create 0 end module Make_single_store (S : STORE) (N : NAME) (V : VALUE) = struct