Added custom exception class and error codes