@@ -27,9 +27,10 @@ import CLC.Stackage.Parser.API.Common
2727import CLC.Stackage.Parser.API.JSON qualified as JSON
2828import CLC.Stackage.Utils.Exception qualified as Ex
2929import CLC.Stackage.Utils.Logging qualified as Logging
30- import Control.Exception (Exception (displayException ))
30+ import Control.Exception (Exception (displayException ), throwIO )
3131import Data.Text qualified as T
3232import Network.HTTP.Client.TLS qualified as TLS
33+ import System.Exit (ExitCode (ExitFailure ))
3334
3435-- | Returns the 'StackageResponse' corresponding to the given snapshot.
3536getStackage :: Logging. Handle -> IO StackageResponse
@@ -38,15 +39,25 @@ getStackage hLogger = do
3839 Ex. tryAny (JSON. getStackage manager stackageSnapshot) >>= \ case
3940 Right r1 -> pure r1
4041 Left jsonEx -> do
41- let msg =
42+ let e1 =
4243 mconcat
4344 [ " Json endpoint failed. Trying cabal config next: " ,
4445 T. pack $ displayException jsonEx
4546 ]
4647
47- Logging. putTimeWarnStr hLogger msg
48+ Logging. putTimeWarnStr hLogger e1
4849
49- CabalConfig. getStackage manager stackageSnapshot
50+ Ex. tryAny (CabalConfig. getStackage manager stackageSnapshot) >>= \ case
51+ Right r2 -> pure r2
52+ Left ex -> do
53+ let e2 =
54+ mconcat
55+ [ " Cabal config endpoint failed: " ,
56+ T. pack $ displayException ex
57+ ]
58+
59+ Logging. putTimeErrStr hLogger e2
60+ throwIO $ ExitFailure 1
5061
5162-- | Stackage snapshot. Currently just 'nightly' to hopefully allow clc-stackage
5263-- to be more flexible.
0 commit comments