From 427a5de1f3a34e495080190e973c0da1703141c7 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 15 Jun 2025 22:06:34 -1000 Subject: [PATCH] dev:MultiBalanceReport: use error' consistently for clean output --- hledger-lib/Hledger/Reports/MultiBalanceReport.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs index 3573a0375..d48e91323 100644 --- a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs +++ b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs @@ -305,6 +305,7 @@ calculateReportAccount rspec@ReportSpec{_rsReportOpts=ropts} j priceoracle colsp intToDay = ModifiedJulianDay . toInteger -- | The valuation function to use for the chosen report options. +-- This can call error in various situations. periodDataValuation :: ReportOpts -> Journal -> PriceOracle -> [DateSpan] -> PeriodData BalanceData -> PeriodData BalanceData periodDataValuation ropts j priceoracle colspans = @@ -320,14 +321,14 @@ periodDataValuation ropts j priceoracle colspans = balanceDataPeriodEnds = dbg5 "balanceDataPeriodEnds" $ case colspans of -- FIXME: Change colspans to nonempty list [DateSpan Nothing Nothing] -> periodDataFromList nulldate [(nulldate, nulldate)] -- Empty journal h:ds -> periodDataFromList (makeJustFst $ boundaries h) $ map (makeJust . boundaries) (h:ds) - [] -> error "balanceDataPeriodEnds: Shouldn't have empty colspans" -- PARTIAL: Shouldn't occur + [] -> error' "balanceDataPeriodEnds: Shouldn't have empty colspans" -- PARTIAL: Shouldn't occur where boundaries spn = (spanStart spn, spanEnd spn) makeJust (Just x, Just y) = (x, addDays (-1) y) - makeJust _ = error "calculateReportAccount: expected all non-initial spans to have start and end dates" + makeJust _ = error' "calculateReportAccount: expected all non-initial spans to have start and end dates" makeJustFst (Just x, _) = addDays (-1) x - makeJustFst _ = error "calculateReportAccount: expected initial span to have an end date" + makeJustFst _ = error' "calculateReportAccount: expected initial span to have an end date" -- | Mark which nodes of an 'Account' are boring, and so should be omitted from reports. markAccountBoring :: ReportSpec -> Account BalanceData -> Account BalanceData