Refactoring.

* Try instead of throwing exceptions.