1
1
mirror of https://github.com/srid/rib.git synced 2024-11-27 01:12:09 +03:00

Don't crash on Shake errors

During the initial full generation we are not handing exceptions from
Shake (which can happen due to parser errors from user code). This
change handles it.
This commit is contained in:
Sridhar Ratnakumar 2019-12-31 20:12:49 -05:00
parent e82ca00c7c
commit 1ef7941ad5

View File

@ -90,7 +90,6 @@ runWith src dst buildAction = \case
putStrLn $ "[Rib] Watching " <> toFilePath src <> " for changes"
void $ watchTree mgr (toFilePath src) (const True) $ \_ -> do
runShake False
`catch` \(e :: SomeException) -> putStrLn $ show e
-- Wait forever, effectively.
forever $ threadDelay maxBound
Serve p dw ->
@ -101,10 +100,14 @@ runWith src dst buildAction = \case
runShake fullGen
where
runShake fullGen =
flip shakeForward buildAction $
shakeOptions
{ shakeVerbosity = Verbose,
shakeRebuild = bool [] [(RebuildNow, "**")] fullGen,
shakeLintInside = [""],
shakeExtra = addShakeExtra (RibSettings src dst) (shakeExtra shakeOptions)
}
shakeForward (ribShakeOptions fullGen) buildAction
-- Gracefully handle any exceptions when running Shake actions. We want
-- Rib to keep running instead of crashing abruptly.
`catch` \(e :: SomeException) -> putStrLn $ "[Rib] Shake error: " <> show e
ribShakeOptions fullGen =
shakeOptions
{ shakeVerbosity = Verbose,
shakeRebuild = bool [] [(RebuildNow, "**")] fullGen,
shakeLintInside = [""],
shakeExtra = addShakeExtra (RibSettings src dst) (shakeExtra shakeOptions)
}