summaryrefslogtreecommitdiff
path: root/src/Data
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-06-11 06:00:57 +0400
committerSam T <pxqr.sta@gmail.com>2013-06-11 06:00:57 +0400
commit1b4fdf35dd6c21d600130c42a1bcb5c56b25afa6 (patch)
tree136bb1467f5d3b5929620ddb0ab2adffc656504d /src/Data
parenta6490c275b6c688df1f654bff92f96aaeb998805 (diff)
~ Use exception in fromFile.
Again, the problem is that one function returns errors in two different ways: Either and IO exceptions. It's better to just throw exception in either case.
Diffstat (limited to 'src/Data')
-rw-r--r--src/Data/Torrent.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Data/Torrent.hs b/src/Data/Torrent.hs
index 3175e151..068e9cb6 100644
--- a/src/Data/Torrent.hs
+++ b/src/Data/Torrent.hs
@@ -55,6 +55,8 @@ import Prelude hiding (sum)
55 55
56import Control.Applicative 56import Control.Applicative
57import Control.Arrow 57import Control.Arrow
58import Control.Exception
59import Control.Monad
58import Data.BEncode as BE 60import Data.BEncode as BE
59import Data.Char 61import Data.Char
60import Data.Foldable 62import Data.Foldable
@@ -353,8 +355,8 @@ isMultiFile MultiFile {} = True
353isMultiFile _ = False 355isMultiFile _ = False
354 356
355-- | Read and decode a .torrent file. 357-- | Read and decode a .torrent file.
356fromFile :: FilePath -> IO (Result Torrent) 358fromFile :: FilePath -> IO Torrent
357fromFile filepath = decoded <$> B.readFile filepath 359fromFile = B.readFile >=> either (throwIO . userError) return . decoded
358 360
359{----------------------------------------------------------------------- 361{-----------------------------------------------------------------------
360 Info hash 362 Info hash