Bug863749 - Add error case and reformat the codes