hledger-lib-1.33: A library providing the core functionality of hledger
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hledger.Data.Errors

Description

Helpers for making error messages.

Synopsis

Documentation

makeAccountTagErrorExcerpt :: (AccountName, AccountDeclarationInfo) -> TagName -> (FilePath, Int, Maybe (Int, Maybe Int), Text) Source #

Given an account name and its account directive, and a problem tag within the latter: render it as a megaparsec-style excerpt, showing the original line number and marked column or region. Returns the file path, line number, column(s) if known, and the rendered excerpt, or as much of these as is possible. The returned columns will be accurate for the rendered error message but not for the original journal data.

makeTransactionErrorExcerpt :: Transaction -> (Transaction -> Maybe (Int, Maybe Int)) -> (FilePath, Int, Maybe (Int, Maybe Int), Text) Source #

Given a problem transaction and a function calculating the best column(s) for marking the error region: render it as a megaparsec-style excerpt, showing the original line number on the transaction line, and a column(s) marker. Returns the file path, line number, column(s) if known, and the rendered excerpt, or as much of these as is possible. The returned columns will be accurate for the rendered error message but not for the original journal data.

makePostingErrorExcerpt :: Posting -> (Posting -> Transaction -> Text -> Maybe (Int, Maybe Int)) -> (FilePath, Int, Maybe (Int, Maybe Int), Text) Source #

Given a problem posting and a function calculating the best column(s) for marking the error region: look up error info from the parent transaction, and render the transaction as a megaparsec-style excerpt, showing the original line number on the problem posting's line, and a column indicator. Returns the file path, line number, column(s) if known, and the rendered excerpt, or as much of these as is possible. A limitation: columns will be accurate for the rendered error message but not for the original journal data.

makePostingAccountErrorExcerpt :: Posting -> (FilePath, Int, Maybe (Int, Maybe Int), Text) Source #

From the given posting, make an error excerpt showing the transaction with this posting's account part highlighted.

makeBalanceAssertionErrorExcerpt :: Posting -> (FilePath, Int, Maybe (Int, Maybe Int), Text) Source #

From the given posting, make an error excerpt showing the transaction with the balance assertion highlighted.

transactionFindPostingIndex :: (Posting -> Bool) -> Transaction -> Maybe Int Source #

Find the 1-based index of the first posting in this transaction satisfying the given predicate.