Throwing exception when cookie error occurs