Fix NPE when logging a certain error