Fix crashes while attempting to log exceptions.