Use custom exception classes to facilitate better error reporting on the client side

Use of generic Exception class makes it harder for the client to properly diagnose and report errors to the end user.