Add NULL pointer check before assignment of NSError.