From b8ef9c927dee32e5629139e4ba5b4dec37fce222 Mon Sep 17 00:00:00 2001 From: schroffl Date: Tue, 24 Dec 2024 12:01:53 +0100 Subject: [PATCH] Add proper, helpful error messages for the dict decoder --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4bb5817..f0df7f9 100644 --- a/index.js +++ b/index.js @@ -283,8 +283,10 @@ if (isOk(child_value)) { result[key] = child_value.value; } else { - // TODO Wrap in key info - return child_value; + var msg = 'Failed to decode dictionary, because attempting to decode the field \'' + key + '\' failed with the following error:\n\n'; + msg += child_value.msg; + msg += '\nwhen attempting to decode the field \'' + key + '\' of\n' + toDebugString(value); + return err(msg); } }