Return error code on error when publishing events