Add error catching for dynamic origin checking

Previous pull request: #11