Improve error handling on publish.