Error handling using Exceptions

Exceptions are being thrown. Use getMessage() and getCode() to get
details. errors.txt contains all the possible error messages and their
codes