add error handling to publishing