Commit 622191ab authored by Steffen Michels's avatar Steffen Michels

dynamic editors: improve abort message in case the JSON value of a custom editor cannot be decoded

parent 22ee0edc
......@@ -586,7 +586,8 @@ where
valueCorrespondingToGen editor json = dynamic (fromJSON` editor json)
where
fromJSON` :: (Editor a) !JSONNode -> a | JSONDecode{|*|} a
fromJSON` _ json = fromMaybe (abort "corrupt dynamic editor value") $ fromJSON json
fromJSON` _ json =
fromMaybe (abort $ corruptValueErrorString ["undecodable JSON ", toString json]) $ fromJSON json
valueCorrespondingToList :: !Dynamic ![(DynamicConsId, DEVal)] -> Dynamic
valueCorrespondingToList funcs args =
......@@ -632,6 +633,9 @@ where
consesOf (DynamicCons cons) = [(cons, Nothing)]
consesOf (DynamicConsGroup label conses) = (\cons -> (cons, Just label)) <$> conses
corruptValueErrorString :: ![String] -> String
corruptValueErrorString errorStrs = concat $ flatten [["Corrupt dynamic editor value: "], errorStrs, [".\n"]]
derive class iTask DynamicEditorValue, DEVal
derive JSONEncode ConsType
derive JSONDecode ConsType
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