Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve errorformat for hledger #157

Merged
merged 1 commit into from
May 7, 2024

Conversation

lakshayg
Copy link
Contributor

@lakshayg lakshayg commented May 4, 2024

The original errorformat was specified as a multiline format followed by an "ignore non-matching lines format". I encountered some cases where this was problematic:

  1. hledger errors have a lot of context spread across multiple lines. Matching everything with 1 multiline format causes vim to move all that information into a single error line which becomes very hard to read.
  2. Removing non-matching lines makes it so that if an error is not recognized by efm then it is completely discarded. This can hide errors from the user. For example, in case of an unbalanced transaction hledger prints something like:
hledger: Error: <filename>:<line1>-<line2>: <line1> | <date>  <payee>
          |      <posting-line1>            <amount>
          |      <posting-line2>            <amount>
          |      <posting-line3>            <amount>
          |      ...
  This transaction is unbalanced.
  The real postings' sum should be 0 but is: <delta>
  Consider adjusting this entry's amounts, or adding missing postings.

This error message does not match the old errorformat in the plugin.

The original errorformat was specified as a multiline format
followed by an "ignore non-matching lines format". I encountered
some cases where this was problematic:

1. hledger errors have a lot of context spread across multiple lines.
   Matching everything with 1 multiline format causes vim to move
   all that information into a single error line which becomes very
   hard to read.
2. Removing non-matching lines makes it so that if an error is not
   recognized by efm then it is completely discarded. This can hide
   errors from the user. For example, in case of an unbalanced
   transaction hledger prints something like:
   ```
   hledger: Error: <filename>:<line1>-<line2>:
   <line1> | <date>  <payee>
           |      <posting-line1>            <amount>
           |      <posting-line2>            <amount>
           |      <posting-line3>            <amount>
           |      ...
   This transaction is unbalanced.
   The real postings' sum should be 0 but is: <delta>
   Consider adjusting this entry's amounts, or adding missing postings.
   ```
   This error message does not match the old errorformat in the plugin.
@alerque alerque merged commit da40d73 into ledger:master May 7, 2024
3 of 5 checks passed
@lakshayg lakshayg deleted the efm_improvements branch May 7, 2024 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants