@@ -207,6 +207,7 @@ module Network.HTTP.Req
207207
208208 -- * Other
209209 HttpException (..),
210+ isStatusCodeException,
210211 CanHaveBody (..),
211212 Scheme (..),
212213 )
@@ -1971,6 +1972,16 @@ class HttpResponse response where
19711972 acceptHeader :: Proxy response -> Maybe ByteString
19721973 acceptHeader Proxy = Nothing
19731974
1975+-- | This instance has been added to make it easier to inspect 'L.Response'
1976+-- using Req's functions like 'responseStatusCode', 'responseStatusMessage',
1977+-- etc.
1978+--
1979+-- @since 3.12.0
1980+instance HttpResponse (L.Response ()) where
1981+ type HttpResponseBody (L.Response ()) = ()
1982+ toVanillaResponse = id
1983+ getHttpResponse = return . void
1984+
19741985----------------------------------------------------------------------------
19751986-- Other
19761987
@@ -2009,6 +2020,20 @@ data HttpException
20092020
20102021instance Exception HttpException
20112022
2023+-- | Return 'Just' if the given 'HttpException' is wrapping a http-client's
2024+-- 'L.StatusCodeException'. Otherwise, return 'Nothing'.
2025+--
2026+-- @since 3.12.0
2027+isStatusCodeException :: HttpException -> Maybe (L.Response ())
2028+isStatusCodeException
2029+ ( VanillaHttpException
2030+ ( L.HttpExceptionRequest
2031+ _
2032+ (L.StatusCodeException r _)
2033+ )
2034+ ) = Just r
2035+isStatusCodeException _ = Nothing
2036+
20122037-- | A simple type isomorphic to 'Bool' that we only have for better error
20132038-- messages. We use it as a kind and its data constructors as type-level
20142039-- tags.