Revision 30d25dd8
b/htools/Ganeti/HTools/ExtLoader.hs | ||
---|---|---|
34 | 34 |
) where |
35 | 35 |
|
36 | 36 |
import Control.Monad |
37 |
import Control.Exception |
|
37 | 38 |
import Data.Maybe (isJust, fromJust) |
39 |
import Prelude hiding (catch) |
|
38 | 40 |
import System.FilePath |
39 | 41 |
import System.IO |
40 | 42 |
import Text.Printf (hPrintf) |
... | ... | |
53 | 55 |
|
54 | 56 |
-- | Error beautifier. |
55 | 57 |
wrapIO :: IO (Result a) -> IO (Result a) |
56 |
wrapIO = flip catch (return . Bad . show)
|
|
58 |
wrapIO = flip catch (\e -> return . Bad . show $ (e::IOException))
|
|
57 | 59 |
|
58 | 60 |
-- | Parses a user-supplied utilisation string. |
59 | 61 |
parseUtilisation :: String -> Result (String, DynUtil) |
b/htools/Ganeti/HTools/Rapi.hs | ||
---|---|---|
30 | 30 |
, parseData |
31 | 31 |
) where |
32 | 32 |
|
33 |
import Control.Exception |
|
33 | 34 |
import Data.List (isPrefixOf) |
34 | 35 |
import Data.Maybe (fromMaybe) |
35 | 36 |
#ifndef NO_CURL |
... | ... | |
37 | 38 |
import Network.Curl.Types () |
38 | 39 |
#endif |
39 | 40 |
import Control.Monad |
41 |
import Prelude hiding (catch) |
|
40 | 42 |
import Text.JSON (JSObject, fromJSObject, decodeStrict) |
41 | 43 |
import Text.JSON.Types (JSValue(..)) |
42 | 44 |
import Text.Printf (printf) |
... | ... | |
83 | 85 |
-- | Helper to convert I/O errors in 'Bad' values. |
84 | 86 |
ioErrToResult :: IO a -> IO (Result a) |
85 | 87 |
ioErrToResult ioaction = |
86 |
catch (ioaction >>= return . Ok) (return . Bad . show) |
|
88 |
catch (ioaction >>= return . Ok) |
|
89 |
(\e -> return . Bad . show $ (e::IOException)) |
|
87 | 90 |
|
88 | 91 |
-- | Append the default port if not passed in. |
89 | 92 |
formatHost :: String -> String |
b/htools/htools.hs | ||
---|---|---|
25 | 25 |
|
26 | 26 |
module Main (main) where |
27 | 27 |
|
28 |
import Control.Exception |
|
29 |
import Control.Monad (guard) |
|
28 | 30 |
import Data.Char (toLower) |
31 |
import Prelude hiding (catch) |
|
29 | 32 |
import System.Environment |
30 | 33 |
import System.Exit |
31 | 34 |
import System.IO |
35 |
import System.IO.Error (isDoesNotExistError) |
|
32 | 36 |
|
33 | 37 |
import Ganeti.HTools.Utils |
34 | 38 |
import Ganeti.HTools.CLI (parseOpts) |
... | ... | |
47 | 51 |
|
48 | 52 |
main :: IO () |
49 | 53 |
main = do |
50 |
binary <- getEnv "HTOOLS" `catch` const getProgName |
|
54 |
binary <- catchJust (guard . isDoesNotExistError) |
|
55 |
(getEnv "HTOOLS") (const getProgName) |
|
51 | 56 |
let name = map toLower binary |
52 | 57 |
boolnames = map (\(x, y) -> (x == name, Just y)) personalities |
53 | 58 |
case select Nothing boolnames of |
Also available in: Unified diff