Catch exceptions

Resolves #15887
Merge pull request #15627 from cachedout/issue_15587

Catch exceptions