From 9af46d4e657bce0a343c7ca0dfacad6696bbf503 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Thu, 6 Feb 2014 05:59:50 +0400 Subject: Add generic tracker RPC exception --- src/Network/BitTorrent/Tracker/RPC.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Network/BitTorrent/Tracker/RPC.hs') diff --git a/src/Network/BitTorrent/Tracker/RPC.hs b/src/Network/BitTorrent/Tracker/RPC.hs index 48048964..0ffb2017 100644 --- a/src/Network/BitTorrent/Tracker/RPC.hs +++ b/src/Network/BitTorrent/Tracker/RPC.hs @@ -122,9 +122,10 @@ withManager opts info = bracket (newManager opts info) closeManager -- TODO Catch IO exceptions on rpc calls (?) data RpcException - = UdpException UDP.RpcException -- ^ - | HttpException HTTP.RpcException -- ^ - | UnknownProtocol String -- ^ unknown tracker protocol scheme + = UdpException UDP.RpcException -- ^ UDP RPC driver failure; + | HttpException HTTP.RpcException -- ^ HTTP RPC driver failure; + | UnrecognizedProtocol String -- ^ unsupported scheme in announce URI; + | GenericException String -- ^ for furter extensibility. deriving (Show, Typeable) instance Exception RpcException @@ -141,7 +142,7 @@ dispatch :: URI -> IO a -> IO a -> IO a dispatch URI {..} http udp | uriScheme == "http:" = packException HttpException http | uriScheme == "udp:" = packException UdpException udp - | otherwise = throwIO $ UnknownProtocol uriScheme + | otherwise = throwIO $ UnrecognizedProtocol uriScheme announce :: Manager -> URI -> SAnnounceQuery -> IO AnnounceInfo announce Manager {..} uri simpleQuery -- cgit v1.2.3