@@ -19,6 +19,7 @@ import Data.Aeson.Types hiding (parse)
19import Text.Libyaml hiding (encode, decode, encodeFile, decodeFile)
19import Text.Libyaml hiding (encode, decode, encodeFile, decodeFile)
20import Data.ByteString (ByteString)
20import Data.ByteString (ByteString)
21import qualified Data.Map as Map
21import qualified Data.Map as Map
22+import Data.Maybe (isNothing)
22import Control.Exception
23import Control.Exception
23import Control.Exception.Enclosed
24import Control.Exception.Enclosed
24import Control.Monad.Trans.State
25import Control.Monad.Trans.State
@@ -79,24 +80,28 @@ prettyPrintParseException :: ParseException -> String
79prettyPrintParseException pe = case pe of
80prettyPrintParseException pe = case pe of
80 NonScalarKey -> "Non scalar key"
81 NonScalarKey -> "Non scalar key"
81 UnknownAlias anchor -> "Unknown alias `" ++ anchor ++ "`"
82 UnknownAlias anchor -> "Unknown alias `" ++ anchor ++ "`"
82− UnexpectedEvent mbExpected mbUnexpected -> case (mbExpected, mbUnexpected) of
83+ UnexpectedEvent mbExpected mbUnexpected ->
84+ assert (not (isNothing mbExpected && isNothing mbUnexpected)) $
85+ case (mbExpected, mbUnexpected) of
83− (Nothing, Nothing) ->
86+ (Nothing, Nothing) -> unlines
84− error $ "prettyPrintYamlParseException: Got UnexpectedEvent with two `Nothing`s"
87+ [ "Got UnexpectedEvent with two `Nothing`s, this should never happen."
88+ , "Please report it as a bug at <https://github.com/snoyberg/yaml/>"
85− (Just expected, Just received) -> unlines
90+ (Just expected, Just received) -> unlines
86− [ "Unexpected event: expected"
91+ [ "Unexpected event: expected"
87− , " " ++ show expected
92+ , " " ++ show expected
88− , "but received"
93+ , "but received"
89− , " " ++ show received
94+ , " " ++ show received
91− (Just expected, Nothing) -> unlines
96+ (Just expected, Nothing) -> unlines
92− [ "Expected event"
97+ [ "Expected event"
93− , " " ++ show expected
98+ , " " ++ show expected
94− , "but got none"
99+ , "but got none"
96− (Nothing, Just received) -> unlines
101+ (Nothing, Just received) -> unlines
97− [ "Expected no events, but received"
102+ [ "Expected no events, but received"
98− , " " ++ show received
103+ , " " ++ show received
100 InvalidYaml mbYamlError -> case mbYamlError of
105 InvalidYaml mbYamlError -> case mbYamlError of
101 Nothing -> "Unspecified YAML error"
106 Nothing -> "Unspecified YAML error"
102 Just yamlError -> case yamlError of
107 Just yamlError -> case yamlError of