Add exceptions definitions
Add proper implementation for throwing exceptions