Catch all io exceptions
This commit is contained in:
parent
67e4c98232
commit
8c9de5cd8b
2 changed files with 3 additions and 12 deletions
|
|
@ -66,9 +66,7 @@ data ErrorAction
|
|||
loadErrorMessage :: IOError -> Maybe ErrorAction
|
||||
loadErrorMessage e
|
||||
| isDoesNotExistError e = Just IgnoreError
|
||||
| isIllegalOperation e = Just $ ErrorMessage $ "Could not open file:\n" ++ show e
|
||||
| isPermissionError e = Just $ ErrorMessage "Could not open file: Permission denied"
|
||||
| otherwise = Nothing
|
||||
| otherwise = Just $ ErrorMessage $ show e
|
||||
|
||||
loadLTasks :: FilePath -> IO (Either String (V.Vector LTask))
|
||||
loadLTasks file = do
|
||||
|
|
@ -78,18 +76,11 @@ loadLTasks file = do
|
|||
Left (ErrorMessage msg) -> pure $ Left msg
|
||||
Right (Left parseError) -> pure $ Left $ parseErrorPretty parseError
|
||||
Right (Right taskList) -> pure $ Right $ V.fromList $ fromTasks taskList
|
||||
--Left parseError -> pure $ Left $ parseErrorPretty parseError
|
||||
--Right taskList -> pure $ Right $ V.fromList $ fromTasks taskList
|
||||
|
||||
{- Saving -}
|
||||
|
||||
saveErrorMessage :: IOError -> Maybe String
|
||||
saveErrorMessage e
|
||||
| isAlreadyInUseError e = Just "Could not save to file: File already in use"
|
||||
| isFullError e = Just "Could not save to file: Disk full"
|
||||
| isIllegalOperation e = Just $ "Could not save to file:\n" ++ show e
|
||||
| isPermissionError e = Just "Could not save to file: Permission denied"
|
||||
| otherwise = Nothing
|
||||
saveErrorMessage e = Just $ show e
|
||||
|
||||
saveLTasks :: FilePath -> V.Vector LTask -> IO (Either String ())
|
||||
saveLTasks file ltasks = do
|
||||
|
|
|
|||
2
todo.txt
2
todo.txt
|
|
@ -19,5 +19,5 @@ x2018-10-24 c2018-10-24 Reverse ordering of completed tasks - most recent at the
|
|||
- c2018-10-26 Move C - cleanup to F - fixup
|
||||
- c2018-10-26 Add "starting" task type (start date, prio, due date, description)
|
||||
- c2018-10-26 Add "formula" task type (formula, prio, due date, description) - maybe due date formula?
|
||||
- (D) c2018-10-26 Fix crash on attempting to open a folder
|
||||
x2018-11-01 (D) c2018-10-26 Fix crash on attempting to open a folder
|
||||
- c2018-10-26 Think of something to do with +project tags, @context tags and key:value tags
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue