Commit 290bcc95 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 3e0d7299
Pipeline #37429 passed with stage
in 6 minutes and 55 seconds
......@@ -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 =
......@@ -594,7 +595,7 @@ where
[] =
case funcs of
((_, g) :: (a -> b, [b] -> c)) = dynamic g []
_ = abort "corrupt dynamic editor valueU"
_ = abort "corrupt dynamic editor value"
// we have to use the first element to update the type,
// the `b` and `c` type variable is required to be equal for all list elements
args=:[fst: _] =
......@@ -635,6 +636,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