summaryrefslogtreecommitdiff
path: root/src/Network/KRPC/Message.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/KRPC/Message.hs')
-rw-r--r--src/Network/KRPC/Message.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Network/KRPC/Message.hs b/src/Network/KRPC/Message.hs
index 3bbfb1db..0bd34400 100644
--- a/src/Network/KRPC/Message.hs
+++ b/src/Network/KRPC/Message.hs
@@ -30,6 +30,7 @@ module Network.KRPC.Message
30 , decodeError 30 , decodeError
31 , unknownMethod 31 , unknownMethod
32 , unknownMessage 32 , unknownMessage
33 , timeoutExpired
33 34
34 -- * Query 35 -- * Query
35 , KQuery(..) 36 , KQuery(..)
@@ -130,17 +131,28 @@ instance BEncode KError where
130 131
131instance Exception KError 132instance Exception KError
132 133
134-- | Happen when some handler fail.
133serverError :: SomeException -> TransactionId -> KError 135serverError :: SomeException -> TransactionId -> KError
134serverError e = KError ServerError (BC.pack (show e)) 136serverError e = KError ServerError (BC.pack (show e))
135 137
138-- | Received 'queryArgs' or 'respVals' can not be decoded.
136decodeError :: String -> TransactionId -> KError 139decodeError :: String -> TransactionId -> KError
137decodeError msg = KError ProtocolError (BC.pack msg) 140decodeError msg = KError ProtocolError (BC.pack msg)
138 141
142-- | If /remote/ node send query /this/ node doesn't know about then
143-- this error message should be sent in response.
139unknownMethod :: MethodName -> TransactionId -> KError 144unknownMethod :: MethodName -> TransactionId -> KError
140unknownMethod = KError MethodUnknown 145unknownMethod = KError MethodUnknown
141 146
147-- | A remote node has send some 'KMessage' this node is unable to
148-- decode.
142unknownMessage :: String -> KError 149unknownMessage :: String -> KError
143unknownMessage msg = KError ProtocolError (BC.pack msg) "" 150unknownMessage msg = KError ProtocolError (BC.pack msg) unknownTransaction
151
152-- | A /remote/ node is not responding to the /our/ request the for
153-- specified period of time.
154timeoutExpired :: TransactionId -> KError
155timeoutExpired = KError GenericError "timeout expired"
144 156
145{----------------------------------------------------------------------- 157{-----------------------------------------------------------------------
146-- Query messages 158-- Query messages