Put publishing into try/except block