Add NULL pointer check before assignment of NSError.
Remove code that creates an NSError that is never used.