From 4210fa09e7b043ff18f71e32e74055fcbb418be1 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 23 Apr 2019 11:28:28 +0300 Subject: [PATCH] Better error message for Data.Yaml.Config #168 --- yaml/ChangeLog.md | 4 ++++ yaml/package.yaml | 2 +- yaml/src/Data/Yaml/Config.hs | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/yaml/ChangeLog.md b/yaml/ChangeLog.md index 0843476..0ddc912 100644 --- a/yaml/ChangeLog.md +++ b/yaml/ChangeLog.md @@ -1,5 +1,9 @@ # ChangeLog for yaml +## 0.11.0.1 + +* Better error messages in the `Data.Yaml.Config` module [#168](https://github.com/snoyberg/yaml/issues/168) + ## 0.11.0.0 * Split out the `libyaml` and `Text.Libyaml` code into its own package. [#145](https://github.com/snoyberg/yaml/issues/145) diff --git a/yaml/package.yaml b/yaml/package.yaml index 5df225b..446d9e5 100644 --- a/yaml/package.yaml +++ b/yaml/package.yaml @@ -1,5 +1,5 @@ name: yaml -version: 0.11.0.0 +version: 0.11.0.1 synopsis: Support for parsing and rendering YAML documents. description: README and API documentation are available at category: Data diff --git a/yaml/src/Data/Yaml/Config.hs b/yaml/src/Data/Yaml/Config.hs index aefa24d..2fb6eb3 100644 --- a/yaml/src/Data/Yaml/Config.hs +++ b/yaml/src/Data/Yaml/Config.hs @@ -197,9 +197,9 @@ loadYamlSettings runTimeFiles compileValues envUsage = do UseCustomEnv env -> return $ applyEnvValue False env value' RequireCustomEnv env -> return $ applyEnvValue True env value' - case fromJSON value of - Error s -> error $ "Could not convert to expected type: " ++ s - Success settings -> return settings + case Y.parseEither parseJSON value of + Left s -> error $ "Could not convert to expected type: " ++ s + Right settings -> return settings -- | Same as @loadYamlSettings@, but get the list of runtime config files from -- the command line arguments.