mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-09 10:17:34 +03:00
show better errors for unbalanced transaction and missing default year
This commit is contained in:
parent
00ad42e629
commit
d1418a2a21
@ -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
|
||||
|
4
Tests.hs
4
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
|
||||
|
Loading…
Reference in New Issue
Block a user