From c7dd1fcc2f733271937d11fd0afb0ef592a7cdee Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 26 Feb 2024 10:25:22 -1000 Subject: [PATCH] ;imp:cli:errors: make file-not-found error more format agnostic --- hledger-lib/Hledger/Read.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hledger-lib/Hledger/Read.hs b/hledger-lib/Hledger/Read.hs index 967bc2293..1c8c936bf 100644 --- a/hledger-lib/Hledger/Read.hs +++ b/hledger-lib/Hledger/Read.hs @@ -335,16 +335,16 @@ readJournalFiles' = orDieTrying . readJournalFiles definputopts orDieTrying :: MonadIO m => ExceptT String m a -> m a orDieTrying a = either (liftIO . fail) return =<< runExceptT a --- | If the specified journal file does not exist (and is not "-"), --- give a helpful error and quit. +-- | If the specified journal file does not exist (and is not "-"), give a helpful error and quit. +-- (Using "journal file" generically here; it could be in any of hledger's supported formats.) requireJournalFileExists :: FilePath -> IO () requireJournalFileExists "-" = return () requireJournalFileExists f = do exists <- doesFileExist f - unless exists $ do -- XXX might not be a journal file - hPutStr stderr $ "The hledger journal file \"" <> f <> "\" was not found.\n" + unless exists $ do + hPutStr stderr $ "The hledger data file \"" <> f <> "\" was not found.\n" hPutStr stderr "Please create it first, eg with \"hledger add\" or a text editor.\n" - hPutStr stderr "Or, specify an existing journal file with -f or LEDGER_FILE.\n" + hPutStr stderr "Or, specify an existing data file with -f or $LEDGER_FILE.\n" exitFailure -- | Ensure there is a journal file at the given path, creating an empty one if needed.