core: report passphrase error separately from others (#1027)

This commit is contained in:
Evgeny Poberezkin
2022-09-06 23:14:58 +01:00
committed by GitHub
parent 7072dd4f7e
commit de2d169fbc
2 changed files with 21 additions and 6 deletions
+9 -1
View File
@@ -124,7 +124,15 @@ sqlCipherExport DBEncryptionConfig {currentKey = DBEncryptionKey key, newKey = D
where
withDB a err =
liftIO (bracket (SQL.open $ T.pack f) SQL.close a)
`catch` \(e :: SomeException) -> liftIO (putStrLn $ "Database error: " <> show e) >> throwDBError (err $ show e)
`catch` (\(e :: SQL.SQLError) -> log' e >> checkSQLError e)
`catch` (\(e :: SomeException) -> log' e >> throwSQLError e)
where
log' e = liftIO . putStrLn $ "Database error: " <> show e
checkSQLError e = case SQL.sqlError e of
SQL.ErrorNotADatabase -> throwDBError $ err SQLiteErrorNotADatabase
_ -> throwSQLError e
throwSQLError :: Show e => e -> m ()
throwSQLError = throwDBError . err . SQLiteError . show
exportSQL =
T.unlines $
keySQL key