Handle promise errors properly.