on master help sign in
Improve parseJSON failure message for Either

This fixes #193.

commite2c042918d15dfed93a1540881d6d6c1ef2be770 authorBryan O'Sullivan <bos@serpentine.com> dateFri 11 Apr 2014, 09:49 (13 years ago) parent24f94ec
1 file changed+4−1
Data/Aeson/Types/Instances.hs+4−1
Data/Aeson/Types/Instances.hs+4−1
@@ -107,7 +107,10 @@ instance (FromJSON a, FromJSON b) => FromJSON (Either a b) where
107107 parseJSON (Object (H.toList -> [(key, value)]))
108108 | key == left = Left <$> parseJSON value
109109 | key == right = Right <$> parseJSON value
110− parseJSON _ = fail ""
110+ parseJSON _ = fail $
111+ "expected an object with a single property " ++
112+ "where the property key should be either " ++
113+ "\"Left\" or \"Right\""
111114 {-# INLINE parseJSON #-}
112115
113116left, right :: Text