Skip to content
Snippets Groups Projects
Verified Commit 66f989e6 authored by Julian Ospald's avatar Julian Ospald :tea:
Browse files

Fix FromJSONKey instances

This led to silent Nothing when the parser failed.
parent eebb91fb
No related branches found
No related tags found
1 merge request!46Version ranges
...@@ -111,10 +111,10 @@ instance ToJSONKey (Maybe Versioning) where ...@@ -111,10 +111,10 @@ instance ToJSONKey (Maybe Versioning) where
instance FromJSONKey (Maybe Versioning) where instance FromJSONKey (Maybe Versioning) where
fromJSONKey = FromJSONKeyTextParser $ \t -> fromJSONKey = FromJSONKeyTextParser $ \t ->
if t == T.pack "unknown_versioning" then pure Nothing else pure $ just t if t == T.pack "unknown_versioning" then pure Nothing else just t
where where
just t = case versioning t of just t = case versioning t of
Right x -> pure x Right x -> pure $ Just x
Left e -> fail $ "Failure in (Maybe Versioning) (FromJSONKey)" <> show e Left e -> fail $ "Failure in (Maybe Versioning) (FromJSONKey)" <> show e
instance ToJSONKey Platform where instance ToJSONKey Platform where
...@@ -157,10 +157,10 @@ instance ToJSONKey (Maybe Version) where ...@@ -157,10 +157,10 @@ instance ToJSONKey (Maybe Version) where
instance FromJSONKey (Maybe Version) where instance FromJSONKey (Maybe Version) where
fromJSONKey = FromJSONKeyTextParser $ \t -> fromJSONKey = FromJSONKeyTextParser $ \t ->
if t == T.pack "unknown_version" then pure Nothing else pure $ just t if t == T.pack "unknown_version" then pure Nothing else just t
where where
just t = case version t of just t = case version t of
Right x -> pure x Right x -> pure $ Just x
Left e -> fail $ "Failure in (Maybe Version) (FromJSONKey)" <> show e Left e -> fail $ "Failure in (Maybe Version) (FromJSONKey)" <> show e
instance ToJSON Version where instance ToJSON Version where
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment