implements custom error class to throw exception