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 <>
Reviewed-by: default avatarBalazs Lecz <>
parent e8230242
......@@ -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.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment