Catch a more broader range of format exceptions.

While using the logstash-gelf library we encountered a case where a NumberFormatException was thrown and not correctly ignored.

In this pull request, we propose to catch more general formatting errrors.