Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Commit

Permalink
Use throwIO instead of throw to raise SSL exceptions.
Browse files Browse the repository at this point in the history
Apart from being the right way to raise an error in IO, it prevents
a nasty "PAP object entered!" runtime crash I encountered using GHC HEAD.
  • Loading branch information
mvv committed Sep 16, 2011
1 parent fd3cbb8 commit 959fe8b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions OpenSSL/Session.hsc
Expand Up @@ -332,13 +332,13 @@ foreign import ccall "SSL_connect" _ssl_connect :: Ptr SSL_ -> IO CInt
foreign import ccall unsafe "SSL_get_error" _ssl_get_error :: Ptr SSL_ -> CInt -> IO CInt

throwSSLException :: CInt -> IO a
throwSSLException (#const SSL_ERROR_ZERO_RETURN ) = throw ConnectionCleanlyClosed
throwSSLException (#const SSL_ERROR_WANT_CONNECT ) = throw WantConnect
throwSSLException (#const SSL_ERROR_WANT_ACCEPT ) = throw WantAccept
throwSSLException (#const SSL_ERROR_WANT_X509_LOOKUP) = throw WantX509Lookup
throwSSLException (#const SSL_ERROR_SYSCALL ) = throw SSLIOError
throwSSLException (#const SSL_ERROR_SSL ) = throw ProtocolError
throwSSLException x = throw (UnknownError (fromIntegral x))
throwSSLException (#const SSL_ERROR_ZERO_RETURN ) = throwIO ConnectionCleanlyClosed
throwSSLException (#const SSL_ERROR_WANT_CONNECT ) = throwIO WantConnect
throwSSLException (#const SSL_ERROR_WANT_ACCEPT ) = throwIO WantAccept
throwSSLException (#const SSL_ERROR_WANT_X509_LOOKUP) = throwIO WantX509Lookup
throwSSLException (#const SSL_ERROR_SYSCALL ) = throwIO SSLIOError
throwSSLException (#const SSL_ERROR_SSL ) = throwIO ProtocolError
throwSSLException x = throwIO (UnknownError (fromIntegral x))

-- | This is the type of an SSL IO operation. EOF and termination are handled
-- by exceptions while everything else is one of these. Note that reading
Expand Down

0 comments on commit 959fe8b

Please sign in to comment.