module System.Socket.Internal.Exception where
import Control.Exception
import Data.Typeable
import Foreign.C.Types
newtype SocketException
= SocketException CInt
deriving (Typeable, Eq, Ord)
instance Exception SocketException
instance Show SocketException where
show e@(SocketException i)
| e == eOK = "eOK"
| e == eINTR = "eINTR"
| e == eAGAIN = "eAGAIN"
| e == eWOULDBLOCK = "eWOULDBLOCK"
| e == eBADF = "eBADF"
| e == eINPROGRESS = "eINPROGRESS"
| e == ePROTONOSUPPORT = "ePROTONOSUPPORT"
| e == eINVAL = "eINVAL"
| e == eCONNREFUSED = "eCONNREFUSED"
| e == eNETUNREACH = "eNETUNREACH"
| e == eNOTCONN = "eNOTCONN"
| e == eALREADY = "eALREADY"
| e == eISCONN = "eISCONN"
| e == eTIMEDOUT = "eTIMEDOUT"
| otherwise = "SocketException " ++ show i
eOK :: SocketException
eOK = SocketException (0)
eINTR :: SocketException
eINTR = SocketException (4)
eAGAIN :: SocketException
eAGAIN = SocketException (11)
eWOULDBLOCK :: SocketException
eWOULDBLOCK = SocketException (11)
eBADF :: SocketException
eBADF = SocketException (9)
eINPROGRESS :: SocketException
eINPROGRESS = SocketException (115)
ePROTONOSUPPORT :: SocketException
ePROTONOSUPPORT = SocketException (93)
eINVAL :: SocketException
eINVAL = SocketException (22)
eCONNREFUSED :: SocketException
eCONNREFUSED = SocketException (111)
eNETUNREACH :: SocketException
eNETUNREACH = SocketException (101)
eNOTCONN :: SocketException
eNOTCONN = SocketException (107)
eALREADY :: SocketException
eALREADY = SocketException (114)
eISCONN :: SocketException
eISCONN = SocketException (106)
eTIMEDOUT :: SocketException
eTIMEDOUT = SocketException (110)