Add error check.

Signed-off-by: Yunchao Chen <chenyc@infthink.com>