diff --git a/Ledger/Parse.hs b/Ledger/Parse.hs index d6d53db04..d17ef8223 100644 --- a/Ledger/Parse.hs +++ b/Ledger/Parse.hs @@ -313,7 +313,7 @@ ledgerTransaction = do let t = LedgerTransaction date status code description comment postings "" case balanceLedgerTransaction t of Right t' -> return t' - Left err -> error err + Left err -> fail err ledgerdate :: GenParser Char LedgerFileCtx Day ledgerdate = try ledgerfulldate <|> ledgerpartialdate @@ -331,7 +331,7 @@ ledgerpartialdate = do (_,m,d) <- md many spacenonewline y <- getYear - when (y==Nothing) $ error "partial date found, but no default year specified" + when (y==Nothing) $ fail "partial date found, but no default year specified" return $ fromGregorian (fromJust y) (read m) (read d) ledgerdatetime :: GenParser Char LedgerFileCtx LocalTime diff --git a/Tests.hs b/Tests.hs index 66496e11d..c9e9a4020 100644 --- a/Tests.hs +++ b/Tests.hs @@ -84,7 +84,9 @@ $ hledger -f sample.ledger balance --depth 1 {- @ $ printf "2009/1/1 a\n b 1.1\n c -1\n" | runhaskell hledger.hs -f- reg 2>&1 ; true -hledger.hs: could not balance this transaction, amounts do not add up to zero: +"-" (line 4, column 1): +unexpected end of input +could not balance this transaction, amounts do not add up to zero: 2009/01/01 a b 1.1 c -1