Skip to content
Snippets Groups Projects
Commit 2befdc14 authored by Iustin Pop's avatar Iustin Pop
Browse files

JSON: improve error reporting


Currently, we list the entire object in error messages. But for large
objects (e.g. an IAllocator message), this makes the output
unreadable, as the elements are containers themselves.

To simplify the reporting, we only list the keys, as this is more
relevent than the values.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarBalazs Lecz <leczb@google.com>
parent e8230242
No related branches found
No related tags found
No related merge requests found
......@@ -130,7 +130,8 @@ loadJSArray s = fromJResult s . J.decodeStrict
fromObj :: (J.JSON a, Monad m) => [(String, J.JSValue)] -> String -> m a
fromObj o k =
case lookup k o of
Nothing -> fail $ printf "key '%s' not found in %s" k (show o)
Nothing -> fail $ printf "key '%s' not found, object contains only %s"
k (show (map fst o))
Just val -> fromKeyValue k val
-- | Reads the value of an optional key in a JSON object.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment