Added custom exceptions [WIP]

Inspired at http://www.doctrine-project.org
There is type casting `(int)`, so strict comparsion is not needed.