Completed the error handling mechanism (#2)