added null check for error objects in couple of files