Fix some error handling on sdk interface.