Handle error for cpDir