diff --git a/htmlreport/cppcheck-htmlreport b/htmlreport/cppcheck-htmlreport index 1ff69fb2d..c2a715949 100755 --- a/htmlreport/cppcheck-htmlreport +++ b/htmlreport/cppcheck-htmlreport @@ -359,7 +359,14 @@ if __name__ == '__main__': output_file.write(" %s %s" % (data['htmlfile'], error['line'], error['id'], error['line'])) output_file.write(HTML_HEAD_END) - lexer = guess_lexer_for_filename(source_filename, '') + try: + lexer = guess_lexer_for_filename(source_filename, '') + except: + sys.stderr.write("ERROR: Couldn't determine lexer for the file' " + source_filename + " '. Won't be able to syntax highlight this file.") + output_file.write("\n Could not generated content because pygments failed to retrieve the determine code type.") + output_file.write("\n Sorry about this.") + continue + if options.source_encoding: lexer.encoding = options.source_encoding