mirror of
https://github.com/aelve/guide.git
synced 2024-11-29 14:35:35 +03:00
Fix acid-state loading (#386)
* Die when the state could not be loaded * Fix database loading * Don't throw exitSuccess
This commit is contained in:
parent
0c50de646b
commit
0e86f61494
@ -31,10 +31,10 @@ import Guide.Logger.Functions
|
||||
--
|
||||
-- /Exception handling:/
|
||||
--
|
||||
-- Uncaught exceptions are caught and logged. Since Servant exceptions don't
|
||||
-- escape Servant, they are logged where they are thrown (see @instance
|
||||
-- MonadError Guider@). Uncaught Servant exceptions are caught and logged in
|
||||
-- Warp.
|
||||
-- Uncaught exceptions are caught, logged, and rethrown. Since Servant
|
||||
-- exceptions don't escape Servant, they are logged where they are thrown
|
||||
-- (see @instance MonadError Guider@). Uncaught Servant exceptions are
|
||||
-- caught and logged in Warp.
|
||||
withLogger :: Config -> (Logger -> IO ()) -> IO ()
|
||||
withLogger Config{..} act = do
|
||||
logLvlEnv <- lookupEnv "LOG_LEVEL"
|
||||
@ -46,8 +46,9 @@ withLogger Config{..} act = do
|
||||
when logToStderr $ sayErr formattedLogLine
|
||||
whenJust logFileHandle $ \h -> hSay h formattedLogLine
|
||||
Di.Core.new logHandler $ \logger ->
|
||||
act logger `catch` \(e :: SomeException) ->
|
||||
act logger `catch` \(e :: SomeException) -> do
|
||||
logErrorIO logger ("uncaught exception: "+||e||+"")
|
||||
throwIO e
|
||||
|
||||
-- | Pretty-print a log line.
|
||||
showLogLine
|
||||
|
@ -149,7 +149,6 @@ dryRun config = withLogger config $ \logger -> do
|
||||
db :: DB <- openLocalStateFrom "state/" (error "couldn't load state")
|
||||
logDebugIO logger "loaded the database successfully"
|
||||
closeAcidState db
|
||||
exitSuccess
|
||||
|
||||
-- | Load 'PublicDB' from given file, create acid-state database from it,
|
||||
-- and exit.
|
||||
@ -162,7 +161,6 @@ loadPublic config path = withLogger config $ \logger ->
|
||||
Acid.update db (ImportPublicDB publicDB)
|
||||
createCheckpointAndClose' db
|
||||
logDebugIO logger "PublicDB imported to GlobalState"
|
||||
exitSuccess
|
||||
|
||||
-- | Dump API docs to the output.
|
||||
apiDocs :: Config -> IO ()
|
||||
|
@ -283,10 +283,16 @@ data Category = Category {
|
||||
}
|
||||
deriving (Show, Generic, Data)
|
||||
|
||||
deriveSafeCopySorted 12 'extension ''Category
|
||||
deriveSafeCopySorted 13 'extension ''Category
|
||||
makeClassWithLenses ''Category
|
||||
|
||||
changelog ''Category (Current 12, Past 11)
|
||||
changelog ''Category (Current 13, Past 12)
|
||||
[Removed "categoryGroup_" [t|Text|]
|
||||
,Added "categoryGroup" [hs|
|
||||
categoryGroup_ |] ]
|
||||
deriveSafeCopySorted 12 'extension ''Category_v12
|
||||
|
||||
changelog ''Category (Past 12, Past 11)
|
||||
[Removed "categoryGroups" [t|Map Text Hue|] ]
|
||||
deriveSafeCopySorted 11 'extension ''Category_v11
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user