Added rescue block

Added rescue block to prevent #4274.

This is for `master` and `2.2-stable`.