Browse Source

Add toError catch-all line to prevent crashing upon unexpected stream error

This is a temporary fix - we will have to revamp the error handling code.
master
Jon Kristensen 13 years ago
parent
commit
b096b2f1b3
  1. 5
      source/Network/Xmpp/Session.hs

5
source/Network/Xmpp/Session.hs

@ -73,21 +73,20 @@ connectTcp address port hostname = do
return $ Left e return $ Left e
Right () -> return $ Right con Right () -> return $ Right con
where where
-- TODO: Descriptive texts in stream errors?
toError (StreamNotStreamElement _name) = toError (StreamNotStreamElement _name) =
XmppStreamError StreamInvalidXml Nothing Nothing XmppStreamError StreamInvalidXml Nothing Nothing
toError (StreamInvalidStreamNamespace _ns) = toError (StreamInvalidStreamNamespace _ns) =
XmppStreamError StreamInvalidNamespace Nothing Nothing XmppStreamError StreamInvalidNamespace Nothing Nothing
toError (StreamInvalidStreamPrefix _prefix) = toError (StreamInvalidStreamPrefix _prefix) =
XmppStreamError StreamBadNamespacePrefix Nothing Nothing XmppStreamError StreamBadNamespacePrefix Nothing Nothing
-- TODO: Catch remaining xmppStartStream errors.
toError (StreamWrongVersion _ver) = toError (StreamWrongVersion _ver) =
XmppStreamError StreamUnsupportedVersion Nothing Nothing XmppStreamError StreamUnsupportedVersion Nothing Nothing
toError (StreamWrongLangTag _) = toError (StreamWrongLangTag _) =
XmppStreamError StreamInvalidXml Nothing Nothing XmppStreamError StreamInvalidXml Nothing Nothing
toError StreamUnknownError = toError StreamUnknownError =
XmppStreamError StreamBadFormat Nothing Nothing XmppStreamError StreamBadFormat Nothing Nothing
-- TODO: Catch remaining xmppStartStream errors.
toError _ = XmppStreamError StreamBadFormat Nothing Nothing
sessionXML :: Element sessionXML :: Element
sessionXML = pickleElem sessionXML = pickleElem

Loading…
Cancel
Save