Issue #4730

Added exception handling for bug reported in issue #4730. My first pull request so I apologize if it is a little messy.