JessicaTegner/pypandoc

KeyError in _classify_pandoc_logging when the message format does not fit the assumptions

massoncl opened this issue · 2 comments

Since #250, I have an issue with the _classify_pandoc_logging function : when the parsed message does not fit the expected format, the parsing can end in a KeyError. For example, pandoc-include has a warning formatted like this:

[Warn] included file not found: path_of_the_file

Warn isn't in the dictionnary of expected log levels, which raises a KeyError on line 422:

yield level_map[level], "\n".join(log_msgs)

hi @massoncl
thanks for catching this.

Which one would you say would be the prefered solution:

  • Just spith it out, and if so on what level.
  • Try to classify these extra messages (more messages like this might pop up in the future)

I'm not very familiar with this codebase, but I'd say both solutions can be implemented: a classification that tries to include all the message types you're aware of, with an additional fallback case to handle new cases. In the fallback, I'd say that re-logging the messages as "warning" would be best.