aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2018-12-14 18:04:52 +0100
committerFélix Sipma <felix.sipma@no-log.org>2018-12-14 18:04:52 +0100
commita679255c8d1bca8363c2b862ad187837a410f77a (patch)
tree9325063311edc09efd7cdeb7659d0a6b4a00e756
parentd40af59f545499badd1750f43681d54f228d8de4 (diff)
support yaml < 0.8.31 (second try)
-rw-r--r--src/Config/FileConfig.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Config/FileConfig.hs b/src/Config/FileConfig.hs
index bb34e04..c599bab 100644
--- a/src/Config/FileConfig.hs
+++ b/src/Config/FileConfig.hs
@@ -33,6 +33,16 @@ instance FromJSON FileConfig where
parseJSON _ = mzero
+#if MIN_VERSION_yaml(0,8,31)
+#else
+data ParseConfigError = ParseConfigError FilePath
+
+instance Show ParseConfigError where
+ show (ParseConfigError fp) = toS ("ParseConfigError: Could not parse config file \"" <> fp <> "\"")
+
+instance Exception ParseConfigError
+#endif
+
instance ToJSON FileConfig where
toJSON (FileConfig mdb minfos mafrom mato mtlength) = object (jdb ++ jinfos ++ jafrom ++ jato ++ jtlength)
where
@@ -55,9 +65,8 @@ parseConfigFile' config = do
Y.decodeThrow content
#else
case (Y.decode content :: Maybe FileConfig) of
- Nothing -> throwIO $ "ParseConfigError: Could not parse config file \"" <> fpConfig <> "\""
+ Nothing -> throwIO (ParseConfigError fpConfig)
Just c -> return c
-
#endif
where
fpConfig = toFilePath config