@@ -113,6 +113,23 @@ modifyFailureProp orig added =
113113 result :: Result ()
114114 result = parse parser ()
115115
116+parserThrowErrorProp :: String -> Property
117+parserThrowErrorProp msg =
118+ result === Error msg
119+ where
120+ parser = const $ parserThrowError [] msg
121+ result :: Result ()
122+ result = parse parser ()
123+
124+parserCatchErrorProp :: String -> Property
125+parserCatchErrorProp msg =
126+ result === Success msg
127+ where
128+ -- Fail, catch, use error message as a successful parse
129+ parser = const $ parserCatchError (fail msg) (\_ err -> pure err)
130+ result :: Result String
131+ result = parse parser ()
132+
116133-- | Perform a structural comparison of the results of two encoding
117134-- methods. Compares decoded values to account for HashMap-driven
118135-- variation in JSON object key ordering.
@@ -306,6 +323,8 @@ tests = testGroup "properties" [
306323 ]
307324 , testGroup "failure messages" [
308325 testProperty "modify failure" modifyFailureProp
326+ , testProperty "parserThrowError" parserThrowErrorProp
327+ , testProperty "parserCatchError" parserCatchErrorProp
309328 ]
310329 , testGroup "generic" [
311330 testGroup "toJSON" [