ChordPro / chordpro

Reference implementation of the ChordPro standard for musical lead sheets.
Other
324 stars 51 forks source link

Assist debugging of embedded abc #170

Open xeruf opened 3 years ago

xeruf commented 3 years ago

Issue

If there is some error in the embedded ABC notation, chordpro spits out roughly this:

Line 3: Unexpected EOF in header definition
convert: unable to open image '/tmp/l07YKFfpjA/tmp1001.svg': No such file or directory @ error/blob.c/OpenBlob/3536.
convert: no images defined `/tmp/l07YKFfpjA/tmp1.jpg' @ error/convert.c/ConvertImageCommand/3322.
=100=> /usr/bin/vendor_perl/../convert -density 600 -background white -trim /tmp/l07YKFfpjA/tmp1001.svg /tmp/l07YKFfpjA/tmp1.jpg
Error in ABC embedding

Lots of text without any informative content - the first and the last line are the only interesting ones.

Idea

It would be nice to omit the lines in between by checking for file existence and then return information on the abc block that failed (there may be multiple), as well as writing that to a file so it can be debugged without hassle.

So, for example:

abcm2ps: Line 3: Unexpected EOF in header definition
Error embedding ABC, please check "/tmp/something.abc"

Where /tmp/something.abc contains the content of the abc block, which for the example below would be:

X:1
CCFE

Sample

For testing, you can use a simple chordpro file containing this (which has an incomplete abc header):

{start_of_abc}
X:1
CCFE
{end_of_abc}

System information

ChordPro version 5.982 Perl version v5.34.0 Perl program /usr/bin/perl Storable 3.23 Resource path /usr/share/perl5/site_perl/App/Music/ChordPro/res Text::Layout 0.021 File::LoadLines 1.021 PDF::API2 2.041 Font::TTF 1.06

sciurius commented 3 years ago

I've added a check for missing/empty result file. Note that this will catch only certain cases.

In general, when you put an empty libe before the {end_of_abc}, you can run the whole .cho file through abcm2ps and may get better diagnostics.

Leave this issue open as a reminder that this should be improved.