diff --git a/Network/RTorrent/Command/Internals.hs b/Network/RTorrent/Command/Internals.hs index 622b51f..7b3065b 100644 --- a/Network/RTorrent/Command/Internals.hs +++ b/Network/RTorrent/Command/Internals.hs @@ -28,7 +28,7 @@ module Network.RTorrent.Command.Internals ( import Control.Applicative import Control.DeepSeq -import Control.Monad.Error +import Control.Monad.Except import Control.Monad.Identity import qualified Codec.Binary.UTF8.String as U @@ -95,7 +95,7 @@ single v@(ValueStruct vars) = maybe single v = fail $ "Failed to match a singleton array, got: " ++ show v parseValue :: (Monad m, XmlRpcType a) => Value -> m a -parseValue = fromRight . runIdentity . runErrorT . fromValue +parseValue = fromRight . runIdentity . runExceptT . fromValue where fromRight (Right r) = return r fromRight (Left e) = fail $ "parseValue failed: " ++ e diff --git a/Network/RTorrent/RPC.hs b/Network/RTorrent/RPC.hs index a010412..a7abdcd 100644 --- a/Network/RTorrent/RPC.hs +++ b/Network/RTorrent/RPC.hs @@ -99,7 +99,7 @@ module Network.RTorrent.RPC ( , callRTorrent ) where -import Control.Monad.Error (ErrorT(..), throwError, strMsg) +import Control.Monad.Except (ExceptT(..), throwError, runExceptT) import Control.Exception import Data.Monoid import qualified Data.ByteString as BS @@ -111,17 +111,17 @@ import qualified Network.RTorrent.Command.Internals as C import Network.RTorrent.CommandList import Network.RTorrent.SCGI -callRTorrentRaw :: HostName -> Int -> C.RTMethodCall -> ErrorT String IO Value +callRTorrentRaw :: HostName -> Int -> C.RTMethodCall -> ExceptT String IO Value callRTorrentRaw host port calls = do let request = Body [] . mconcat . LB.toChunks $ renderCall call - Body _ content <- ErrorT $ query host port request + Body _ content <- ExceptT $ query host port request let cs = map (toEnum . fromEnum) $ BS.unpack content response <- parseResponse cs case response of Return ret -> case ret of ValueArray arr -> return $ ValueArray arr - val -> throwError . strMsg $ "Got value of type " ++ show (getType val) - Fault code err -> throwError . strMsg $ show code ++ ": " ++ err + val -> throwError $ "Got value of type " ++ show (getType val) + Fault code err -> throwError $ show code ++ ": " ++ err where call = MethodCall "system.multicall" [C.runRTMethodCall calls] @@ -134,7 +134,7 @@ callRTorrent :: Command a => -> a -> IO (Either String (Ret a)) callRTorrent host port command = - (runErrorT $ do + (runExceptT $ do ret <- callRTorrentRaw host port (C.commandCall command) C.commandValue command ret) `catches` [ Handler (\e -> return . Left $ show (e :: IOException)) diff --git a/rtorrent-rpc.cabal b/rtorrent-rpc.cabal index 39b1323..937ab79 100644 --- a/rtorrent-rpc.cabal +++ b/rtorrent-rpc.cabal @@ -36,7 +36,7 @@ library mtl >=2.1 && <2.3, bytestring >=0.10 && <0.11 , network >=2.6, - haxr >=3000.10.3.1 && <3000.11, + haxr >=3000.10.4.2 && <3000.10.5, blaze-builder >=0.3 && <0.4, blaze-textual >=0.2 && <0.3, attoparsec >=0.12 && <0.13,