move from exceptions as StreamHandle error indicator to XmppFailure error values.
This changes the return type of at least the following functions from IO Bool to IO (Either XmppFailure ())
* sendIQ
* sendIQ'
* answerIQ
* sendMessage
* sendPresence
-- | Sends an IQ, returns Just a 'TMVar' that will be filled with the first
-- | Sends an IQ, returns Right 'TMVar' that will be filled with the first
-- inbound IQ with a matching ID that has type @result@ or @error@ or Nothing if
-- the stanza could not be sent
-- the stanza could not be sent.
-- Returns Left 'XmppFailure' when sending the stanza failed
sendIQ::MaybeInteger-- ^ Timeout . When the timeout is reached the response
-- TMVar will be filled with 'IQResponseTimeout' and the
-- id is removed from the list of IQ handlers. 'Nothing'
@ -28,7 +30,7 @@ sendIQ :: Maybe Integer -- ^ Timeout . When the timeout is reached the response
@@ -28,7 +30,7 @@ sendIQ :: Maybe Integer -- ^ Timeout . When the timeout is reached the response
-- default)
->Element-- ^ The IQ body (there has to be exactly one)
@ -38,15 +40,15 @@ sendIQ timeOut to tp lang body session = do -- TODO: Add timeout
@@ -38,15 +40,15 @@ sendIQ timeOut to tp lang body session = do -- TODO: Add timeout
-- TODO: Check for id collisions (shouldn't happen?)
@ -56,18 +58,28 @@ sendIQ timeOut to tp lang body session = do -- TODO: Add timeout
@@ -56,18 +58,28 @@ sendIQ timeOut to tp lang body session = do -- TODO: Add timeout
->[Annotation]-- ^ annotations added by previous handlers
->IO[(Stanza,[Annotation])]-- ^ modified stanzas and
@ -40,14 +40,15 @@ getAnnotation = foldr (\(Annotation a) b -> maybe b Just $ cast a) Nothing . snd
@@ -40,14 +40,15 @@ getAnnotation = foldr (\(Annotation a) b -> maybe b Just $ cast a) Nothing . snd
dataPlugin'=Plugin'{inHandler::Stanza
->[Annotation]
->IO[(Stanza,[Annotation])]
,outHandler::Stanza->IOBool
,outHandler::Stanza->IO(EitherXmppFailure())
-- | In order to allow plugins to tie the knot (Plugin
-- / Session) we pass the plugin the completed Session
-- | Signals an XMPP stream error or another unpredicted stream-related
-- situation. This error is fatal, and closes the XMPP stream.
dataXmppFailure=StreamErrorFailureStreamErrorInfo-- ^ An error XML stream
@ -507,7 +512,7 @@ data XmppFailure = StreamErrorFailure StreamErrorInfo -- ^ An error XML stream
@@ -507,7 +512,7 @@ data XmppFailure = StreamErrorFailure StreamErrorInfo -- ^ An error XML stream
-- failed.
|XmppIllegalTcpDetails-- ^ The TCP details provided did not
-- validate.
|TlsErrorTLSError-- ^ An error occurred in the
|TlsErrorXmppTlsError-- ^ An error occurred in the
-- TLS layer
|TlsNoServerSupport-- ^ The server does not support
-- the use of TLS
@ -522,6 +527,7 @@ data XmppFailure = StreamErrorFailure StreamErrorInfo -- ^ An error XML stream
@@ -522,6 +527,7 @@ data XmppFailure = StreamErrorFailure StreamErrorInfo -- ^ An error XML stream
-- the log.
|XmppIOExceptionIOException-- ^ An 'IOException'
-- occurred
|XmppInvalidXmlString-- ^ Received data is not valid XML
deriving(Show,Eq,Typeable)
instanceExceptionXmppFailure
@ -649,9 +655,10 @@ data ConnectionState
@@ -649,9 +655,10 @@ data ConnectionState
-- | Defines operations for sending, receiving, flushing, and closing on a
-- stream.
dataStreamHandle=
StreamHandle{streamSend::BS.ByteString->IOBool-- ^ Sends may not