imp: include: give a clearer error for trying to include a csv file

And note that other read errors may be unclear when occurring in included files.
This commit is contained in:
Simon Michael 2025-07-15 11:49:17 -07:00
parent 8215f19baa
commit b35dcfda28
2 changed files with 7 additions and 3 deletions

View File

@ -46,7 +46,12 @@ reader sep = Reader
{rFormat = Sep sep
,rExtensions = [show sep]
,rReadFn = parse sep
,rParser = error' "sorry, CSV files can't be included yet" -- PARTIAL:
,rParser = fail "sorry, CSV files can't be included yet" -- PARTIAL:
-- This unnecessarily shows the CSV file's first line in the error message,
-- but gives a more useful message than just calling error'.
-- XXX Note every call to error' in Hledger.Read.* is potentially a similar problem -
-- the error message is good enough when the file was specified directly by the user,
-- but not good if it was loaded by a possibly long chain of include directives.
}
-- | Parse and post-process a "Journal" from CSV data, or give an error.

View File

@ -1,4 +1,3 @@
$$$ hledger check -f csvnoinclude.j
>>>2 /Error: sorry, CSV files can't be included yet
/
>>>2 /CSV files can't be included yet/
>>>= 1