fix error handle bugs

Change-Id: Icbc1e695e8b81843125d7981abb05f8e20f1dfc8