on master help sign in
Be less strict when pretty-printing `UnexpectedEvent`.

Rationale: while I don't think that two `Nothing`s make sense there, I think the current code might allow that to happen, and I don't want to take a bet and throw unwarranted exceptions or wrong error messages. So I'm reverting to the old behaviour.

commitaa1dce9f16413a9774f063515ffa9b1b8449172b authorFrancesco Mazzoli <f@mazzo.li> dateSat 29 Aug 2015, 09:56 (11 years ago) parent59bff10
1 file changed+6−22
Data/Yaml/Internal.hs+6−22
Data/Yaml/Internal.hs+6−22
@@ -80,28 +80,12 @@ prettyPrintParseException :: ParseException -> String
8080prettyPrintParseException pe = case pe of
8181 NonScalarKey -> "Non scalar key"
8282 UnknownAlias anchor -> "Unknown alias `" ++ anchor ++ "`"
83− UnexpectedEvent mbExpected mbUnexpected ->
84− assert (not (isNothing mbExpected && isNothing mbUnexpected)) $
85− case (mbExpected, mbUnexpected) of
86− (Nothing, Nothing) -> unlines
87− [ "Got UnexpectedEvent with two `Nothing`s, this should never happen."
88− , "Please report it as a bug at <https://github.com/snoyberg/yaml/>"
89− ]
90− (Just expected, Just received) -> unlines
91− [ "Unexpected event: expected"
92− , " " ++ show expected
93− , "but received"
94− , " " ++ show received
95− ]
96− (Just expected, Nothing) -> unlines
97− [ "Expected event"
98− , " " ++ show expected
99− , "but got none"
100− ]
101− (Nothing, Just received) -> unlines
102− [ "Expected no events, but received"
103− , " " ++ show received
104− ]
83+ UnexpectedEvent mbExpected mbUnexpected -> unlines
84+ [ "Unexpected event: expected"
85+ , " " ++ show mbExpected
86+ , "but received"
87+ , " " ++ show mbUnexpected
88+ ]
10589 InvalidYaml mbYamlError -> case mbYamlError of
10690 Nothing -> "Unspecified YAML error"
10791 Just yamlError -> case yamlError of