adding custom exceptions for internal errors

* adding exceptions
* adding exceptions handling