Added more specific exceptions to increase control outside module.

This makes it easier to catch more specific issues outside the scope of the module.