The $cdError may contains nothing. Add check for it.