Merge branch 'master' into master-ios

This commit is contained in:
spaced4ndy
2023-05-23 18:40:52 +04:00
3 changed files with 7 additions and 2 deletions
+5 -2
View File
@@ -25,6 +25,7 @@ import Simplex.Messaging.Util
import System.FilePath
import UnliftIO.Directory
import UnliftIO.Exception (SomeException, bracket, catch)
import qualified UnliftIO.Exception as E
import UnliftIO.STM
import UnliftIO.Temporary
@@ -57,7 +58,8 @@ importArchive cfg@ArchiveConfig {archivePath} =
backup agentDb
copyFile (dir </> archiveChatDbFile) chatDb
copyFile (dir </> archiveAgentDbFile) agentDb
copyFiles dir filesPath `catchError` \e -> pure [AEImport e]
copyFiles dir filesPath
`E.catch` \(e :: E.SomeException) -> pure [AEImport . ChatError . CEException $ show e]
where
backup f = whenM (doesFileExist f) $ copyFile f $ f <> ".bak"
copyFiles dir filesPath = do
@@ -82,7 +84,8 @@ copyDirectoryFiles fromDir toDir = do
foldM copyFileCatchError [] fs
where
copyFileCatchError fileErrs f =
(copyDirectoryFile f $> fileErrs) `catchError` \e -> pure (AEImportFile f e : fileErrs)
(copyDirectoryFile f $> fileErrs)
`E.catch` \(e :: E.SomeException) -> pure (AEImportFile f (ChatError . CEException $ show e) : fileErrs)
copyDirectoryFile f = do
let fn = takeFileName f
f' = fromDir </> fn
+1
View File
@@ -827,6 +827,7 @@ data ChatErrorType
| CEAgentCommandError {message :: String}
| CEInvalidFileDescription {message :: String}
| CEInternalError {message :: String}
| CEException {message :: String}
deriving (Show, Exception, Generic)
instance ToJSON ChatErrorType where
+1
View File
@@ -1437,6 +1437,7 @@ viewChatError logLevel = \case
CEAgentCommandError e -> ["agent command error: " <> plain e]
CEInvalidFileDescription e -> ["invalid file description: " <> plain e]
CEInternalError e -> ["internal chat error: " <> plain e]
CEException e -> ["exception: " <> plain e]
-- e -> ["chat error: " <> sShow e]
ChatErrorStore err -> case err of
SEDuplicateName -> ["this display name is already used by user, contact or group"]