[core] Correct error handling.