File tree Expand file tree Collapse file tree 5 files changed +12
-12
lines changed Expand file tree Collapse file tree 5 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ import Control.Monad (forM, forM_)
15
15
import Data.Maybe (catMaybes )
16
16
import qualified Data.Text as T
17
17
import qualified Database.SQLite.Simple as Sqlite
18
- import Prelude hiding (catch )
19
18
import System.Environment (getProgName )
20
19
21
20
Original file line number Diff line number Diff line change @@ -6,14 +6,13 @@ module NumberSix.Handlers.Http
6
6
7
7
8
8
--------------------------------------------------------------------------------
9
- import Control.Exception (SomeException (.. ), catch )
9
+ import Control.Exception (SomeException (.. ), handle )
10
10
import Control.Monad.Trans (liftIO )
11
11
import Data.Text (Text )
12
12
import qualified Data.Text as T
13
13
import qualified Data.Text.Encoding as T
14
14
import qualified Network.HTTP.Conduit as H
15
15
import qualified Network.HTTP.Types as H
16
- import Prelude hiding (catch )
17
16
18
17
19
18
--------------------------------------------------------------------------------
@@ -48,8 +47,9 @@ http uri = do
48
47
--------------------------------------------------------------------------------
49
48
-- | Catch possible network errors
50
49
wrapped :: Text -> IO Text
51
- wrapped uri = catch (http uri) $ \ (SomeException e) ->
52
- return $ T. pack $ show e
50
+ wrapped uri = handle
51
+ (\ (SomeException e) -> return $ T. pack $ show e)
52
+ (http uri)
53
53
54
54
55
55
--------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -7,12 +7,11 @@ module NumberSix.Handlers.NowPlaying
7
7
8
8
--------------------------------------------------------------------------------
9
9
import Control.Applicative ((<$>) )
10
- import Control.Exception
10
+ import Control.Exception ( SomeException ( .. ), handle )
11
11
import Control.Monad.Trans (liftIO )
12
12
import Data.Text (Text )
13
13
import qualified Data.Text.Encoding as T
14
14
import qualified Network.HTTP.Conduit as HC
15
- import Prelude hiding (catch )
16
15
import Text.XmlHtml
17
16
import Text.XmlHtml.Cursor
18
17
@@ -62,8 +61,8 @@ rgrfm = do
62
61
63
62
--------------------------------------------------------------------------------
64
63
urgent :: IO Text
65
- urgent = catch
66
- (T. decodeUtf8 <$> http url id ) ( \ ( SomeException _) -> randomError )
64
+ urgent = handle
65
+ (\ ( SomeException _) -> randomError) ( T. decodeUtf8 <$> http url id )
67
66
where
68
67
url = " http://urgent.fm/nowplaying/livetrack.txt"
69
68
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ resto arg = do
63
63
url = " http://zeus.ugent.be/hydra/api/1.0/resto/week/" ++
64
64
dropWhile (== ' 0' ) week ++ " .json"
65
65
66
+ print url
66
67
http (T. pack url) id >>= \ bs -> case parseJsonEither bs of
67
68
Left _ -> randomError
68
69
Right (WeekMenu m) -> return $ case M. lookup (T. pack day) m of
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ module NumberSix.Handlers.Weather
10
10
11
11
--------------------------------------------------------------------------------
12
12
import Control.Applicative ((<$>) , (<*>) )
13
- import Control.Exception (catch )
13
+ import Control.Exception (handle )
14
14
import Control.Monad (mzero )
15
15
import Control.Monad.Trans (liftIO )
16
16
import Data.Aeson (FromJSON (.. ), Value (.. ), (.:) )
@@ -77,8 +77,9 @@ instance Show Description where
77
77
--------------------------------------------------------------------------------
78
78
getWeather :: Text -> IO (Maybe Weather )
79
79
getWeather query = do
80
- result <- ((parseJsonEither <$> http url id ) :: IO (Either String Weather ))
81
- `catch` (\ ex -> return $ Left $ show (ex :: HttpException ))
80
+ result <- handle
81
+ (\ ex -> return $ Left $ show (ex :: HttpException ))
82
+ ((parseJsonEither <$> http url id ) :: IO (Either String Weather ))
82
83
either (const $ return Nothing ) (return . Just ) result
83
84
where
84
85
loc = if T. null query then " gent" else query
You can’t perform that action at this time.
0 commit comments