In the case of lilypond syntax errors, it really shouldn't carry on and try and push it through ghostscript. Extracting the error and showing it to the user would be good
e.g. from bug 47534
Processing `.../file.ly'
Parsing...
.../file.ly:14:0: error: syntax error, unexpected \header
\header {
.../file.ly:34:24: error: syntax error, unexpected '}'
}Interpreting music... [8]
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
Layout output to `file.eps'...
Converting to PNG...GS exited with status: 9
Version: unspecified
Severity: enhancement