diff options
Diffstat (limited to 'src/Network/KRPC/Message.hs')
-rw-r--r-- | src/Network/KRPC/Message.hs | 14 |
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 | ||
131 | instance Exception KError | 132 | instance Exception KError |
132 | 133 | ||
134 | -- | Happen when some handler fail. | ||
133 | serverError :: SomeException -> TransactionId -> KError | 135 | serverError :: SomeException -> TransactionId -> KError |
134 | serverError e = KError ServerError (BC.pack (show e)) | 136 | serverError e = KError ServerError (BC.pack (show e)) |
135 | 137 | ||
138 | -- | Received 'queryArgs' or 'respVals' can not be decoded. | ||
136 | decodeError :: String -> TransactionId -> KError | 139 | decodeError :: String -> TransactionId -> KError |
137 | decodeError msg = KError ProtocolError (BC.pack msg) | 140 | decodeError 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. | ||
139 | unknownMethod :: MethodName -> TransactionId -> KError | 144 | unknownMethod :: MethodName -> TransactionId -> KError |
140 | unknownMethod = KError MethodUnknown | 145 | unknownMethod = KError MethodUnknown |
141 | 146 | ||
147 | -- | A remote node has send some 'KMessage' this node is unable to | ||
148 | -- decode. | ||
142 | unknownMessage :: String -> KError | 149 | unknownMessage :: String -> KError |
143 | unknownMessage msg = KError ProtocolError (BC.pack msg) "" | 150 | unknownMessage 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. | ||
154 | timeoutExpired :: TransactionId -> KError | ||
155 | timeoutExpired = KError GenericError "timeout expired" | ||
144 | 156 | ||
145 | {----------------------------------------------------------------------- | 157 | {----------------------------------------------------------------------- |
146 | -- Query messages | 158 | -- Query messages |