Addition of custom error object and associated logic.