File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -4,19 +4,16 @@ module Github.Data.Definitions where
44
55import Data.Time
66import Data.Data
7- import Network.HTTP.Conduit (HttpException (.. ))
87import qualified Control.Exception as E
98
10- deriving instance Eq Network.HTTP.Conduit. HttpException
11-
129-- | Errors have been tagged according to their source, so you can more easily
1310-- dispatch and handle them.
1411data Error =
15- HTTPConnectionError E. IOException -- ^ A HTTP error occurred. The actual caught error is included, if available .
12+ HTTPConnectionError E. SomeException -- ^ A HTTP error occurred. The actual caught error is included.
1613 | ParseError String -- ^ An error in the parser itself.
1714 | JsonError String -- ^ The JSON is malformed or unexpected.
1815 | UserError String -- ^ Incorrect input.
19- deriving ( Show , Eq )
16+ deriving Show
2017
2118-- | A date in the Github format, which is a special case of ISO-8601.
2219newtype GithubDate = GithubDate { fromGithubDate :: UTCTime }
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ githubAPI method url body = do
3737 result
3838 where encodedBody = RequestBodyLBS $ encode $ toJSON body
3939
40- doHttps :: BS. ByteString -> String -> Maybe (RequestBody IO ) -> IO (Either E. IOException (Response LBS. ByteString ))
40+ doHttps :: BS. ByteString -> String -> Maybe (RequestBody IO ) -> IO (Either E. SomeException (Response LBS. ByteString ))
4141doHttps method url body = do
4242 let (Just uri) = parseURI url
4343 (Just host) = uriRegName uri
@@ -52,7 +52,15 @@ doHttps method url body = do
5252 , queryString = queryString
5353 }
5454
55- (getResponse request >>= return . Right ) `catch` (return . Left )
55+ (getResponse request >>= return . Right ) `E.catches` [
56+ -- Re-throw AsyncException, otherwise execution will not terminate on
57+ -- SIGINT (ctrl-c). All AsyncExceptions are re-thrown (not just
58+ -- UserInterrupt) because all of them indicate severe conditions and
59+ -- should not occur during normal operation.
60+ E. Handler (\ e -> E. throw (e :: E. AsyncException )),
61+
62+ E. Handler (\ e -> (return . Left ) (e :: E. SomeException ))
63+ ]
5664 where
5765 getResponse request = withManager $ \ manager -> httpLbs request manager
5866
You can’t perform that action at this time.
0 commit comments