diff options
Diffstat (limited to 'src/Network/BitTorrent/Exchange/Session.hs')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Session.hs | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/src/Network/BitTorrent/Exchange/Session.hs b/src/Network/BitTorrent/Exchange/Session.hs index ffc7816e..d2a9aaaf 100644 --- a/src/Network/BitTorrent/Exchange/Session.hs +++ b/src/Network/BitTorrent/Exchange/Session.hs | |||
@@ -22,6 +22,11 @@ import Network.BitTorrent.Exchange.Status | |||
22 | 22 | ||
23 | type Extension = () | 23 | type Extension = () |
24 | 24 | ||
25 | data ExchangeError | ||
26 | = InvalidPieceIx PieceIx | ||
27 | | InvalidBlock BlockIx | ||
28 | | CorruptedPiece PieceIx | ||
29 | |||
25 | -- | Peer session contain all data necessary for peer to peer | 30 | -- | Peer session contain all data necessary for peer to peer |
26 | -- communication. | 31 | -- communication. |
27 | data ExchangeSession = ExchangeSession | 32 | data ExchangeSession = ExchangeSession |
@@ -69,30 +74,6 @@ $(makeLenses ''SessionState) | |||
69 | --getSessionState :: PeerSession -> IO SessionState | 74 | --getSessionState :: PeerSession -> IO SessionState |
70 | --getSessionState PeerSession {..} = readIORef sessionState | 75 | --getSessionState PeerSession {..} = readIORef sessionState |
71 | 76 | ||
72 | {----------------------------------------------------------------------- | ||
73 | -- Exceptions | ||
74 | -----------------------------------------------------------------------} | ||
75 | |||
76 | -- | Exceptions used to interrupt the current P2P session. This | ||
77 | -- exceptions will NOT affect other P2P sessions, DHT, peer <-> | ||
78 | -- tracker, or any other session. | ||
79 | -- | ||
80 | data ExchangeFailure | ||
81 | = PeerDisconnected | ||
82 | | ProtocolError Doc | ||
83 | | UnknownTorrent InfoHash | ||
84 | deriving (Show, Typeable) | ||
85 | |||
86 | instance Exception ExchangeFailure | ||
87 | |||
88 | -- | Do nothing with exception, used with 'handle' or 'try'. | ||
89 | isSessionException :: Monad m => ExchangeFailure -> m () | ||
90 | isSessionException _ = return () | ||
91 | |||
92 | -- | The same as 'isSessionException' but output to stdout the catched | ||
93 | -- exception, for debugging purposes only. | ||
94 | putSessionException :: ExchangeFailure -> IO () | ||
95 | putSessionException = print | ||
96 | {- | 77 | {- |
97 | {----------------------------------------------------------------------- | 78 | {----------------------------------------------------------------------- |
98 | -- Broadcasting: Have, Cancel, Bitfield, SuggestPiece | 79 | -- Broadcasting: Have, Cancel, Bitfield, SuggestPiece |