From 6a062ff9c15c41c9f495966d6e9cfdee882fb1a4 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 18 Apr 2011 11:55:24 +0200 Subject: [PATCH] htools: make some error messages more explicit Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- htools/Ganeti/HTools/ExtLoader.hs | 4 ++-- htools/Ganeti/HTools/Luxi.hs | 3 ++- htools/Ganeti/HTools/Rapi.hs | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htools/Ganeti/HTools/ExtLoader.hs b/htools/Ganeti/HTools/ExtLoader.hs index 9be8dc7ce..3374de6c9 100644 --- a/htools/Ganeti/HTools/ExtLoader.hs +++ b/htools/Ganeti/HTools/ExtLoader.hs @@ -116,8 +116,8 @@ loadExternalData opts = do (case ldresult of Ok x -> return x Bad s -> do - hPrintf stderr "Error: failed to load data. Details:\n%s\n" s - :: IO () + hPrintf stderr + "Error: failed to load data, aborting. Details:\n%s\n" s:: IO () exitWith $ ExitFailure 1 ) let (fix_msgs, nl) = checkData (cdNodes cdata) (cdInstances cdata) diff --git a/htools/Ganeti/HTools/Luxi.hs b/htools/Ganeti/HTools/Luxi.hs index d918ecfeb..28128fc03 100644 --- a/htools/Ganeti/HTools/Luxi.hs +++ b/htools/Ganeti/HTools/Luxi.hs @@ -59,7 +59,8 @@ genericConvert :: (Text.JSON.JSON a) => -> JSValue -- ^ The value we try to convert -> Result a -- ^ The annotated result genericConvert otype oname oattr = - annotateResult (otype ++ " '" ++ oname ++ "', attribute '" ++ + annotateResult (otype ++ " '" ++ oname ++ + "', error while reading attribute '" ++ oattr ++ "'") . fromJVal -- * Data querying functionality diff --git a/htools/Ganeti/HTools/Rapi.hs b/htools/Ganeti/HTools/Rapi.hs index 936fc4428..fbcbf4bbe 100644 --- a/htools/Ganeti/HTools/Rapi.hs +++ b/htools/Ganeti/HTools/Rapi.hs @@ -107,7 +107,7 @@ parseInstance :: NameAssoc -> Result (String, Instance.Instance) parseInstance ktn a = do name <- tryFromObj "Parsing new instance" a "name" - let owner_name = "Instance '" ++ name ++ "'" + let owner_name = "Instance '" ++ name ++ "', error while parsing data" let extract s x = tryFromObj owner_name x s disk <- extract "disk_usage" a beparams <- liftM fromJSObject (extract "beparams" a) @@ -131,7 +131,7 @@ parseInstance ktn a = do parseNode :: NameAssoc -> [(String, JSValue)] -> Result (String, Node.Node) parseNode ktg a = do name <- tryFromObj "Parsing new node" a "name" - let desc = "Node '" ++ name ++ "'" + let desc = "Node '" ++ name ++ "', error while parsing data" extract s = tryFromObj desc a s offline <- extract "offline" drained <- extract "drained" -- GitLab