@@ -207,6 +207,7 @@ module Network.HTTP.Req
208 -- * Other
208 -- * Other
209 HttpException (..),
209 HttpException (..),
210+ isStatusCodeException,
210 CanHaveBody (..),
211 CanHaveBody (..),
211 Scheme (..),
212 Scheme (..),
@@ -1971,6 +1972,16 @@ class HttpResponse response where
1971 acceptHeader :: Proxy response -> Maybe ByteString
1972 acceptHeader :: Proxy response -> Maybe ByteString
1972 acceptHeader Proxy = Nothing
1973 acceptHeader Proxy = Nothing
1975+-- | This instance has been added to make it easier to inspect 'L.Response'
1976+-- using Req's functions like 'responseStatusCode', 'responseStatusMessage',
1980+instance HttpResponse (L.Response ()) where
1981+ type HttpResponseBody (L.Response ()) = ()
1982+ toVanillaResponse = id
1983+ getHttpResponse = return . void
1974----------------------------------------------------------------------------
1985----------------------------------------------------------------------------
@@ -2009,6 +2020,20 @@ data HttpException
2010instance Exception HttpException
2021instance Exception HttpException
2023+-- | Return 'Just' if the given 'HttpException' is wrapping a http-client's
2024+-- 'L.StatusCodeException'. Otherwise, return 'Nothing'.
2027+isStatusCodeException :: HttpException -> Maybe (L.Response ())
2028+isStatusCodeException
2029+ ( VanillaHttpException
2030+ ( L.HttpExceptionRequest
2032+ (L.StatusCodeException r _)
2035+isStatusCodeException _ = Nothing
2012-- | A simple type isomorphic to 'Bool' that we only have for better error
2037-- | A simple type isomorphic to 'Bool' that we only have for better error
2013-- messages. We use it as a kind and its data constructors as type-level
2038-- messages. We use it as a kind and its data constructors as type-level