     /// - Parameters:
     ///   - domain: error domain
     ///   - error: error code
-    func cancel(domain: String = DNSSDNetService.netServiceErrorDomain, error: Any = DNSSDNetService.ErrorCode.cancelledError) {
+    func cancel(domain d: String = DNSSDNetService.netServiceErrorDomain, error e: Any = DNSSDNetService.ErrorCode.cancelledError) {
         if let sd = sd {
             DNSServiceRefDeallocate(sd)
             self.sd = nil
-            let dict: DNSSDNetService.ErrorDictionary = [
-                DNSSDNetService.errorDomain : domain,
-                DNSSDNetService.errorCode   : error
-            ]
-            if isResolving {
-                isResolving = false
-                delegate?.netService(self, didNotResolve: dict)
-            }
-            if isPublishing {
-                isPublishing = false
-                delegate?.netService(self, didNotPublish: dict)
-            }
+            finished(domain: d, error: e)
         }
     }
 

            let this = Unmanaged<DNSSDNetService>.fromOpaque(context).takeRetainedValue()
            if let name = name, let n = String(validatingUTF8: name) { this._name = n }
            if let host = host, let h = String(validatingUTF8: host) { this.hostName = h }
            this.lastError = Int(err)
            guard this.lastError == kDNSServiceErr_NoError else {
                this.delegate?.netService(this, didNotResolve: this.errorDictionary)
                return
            }
            this.delegate?.netServiceDidResolveAddress(this)
        }, this))
        guard lastError == kDNSServiceErr_NoError else {
            delegate?.netService(self, didNotResolve: errorDictionary)

            if let name = name, let n = String(validatingUTF8: name) { this._name = n }
            if let type = regType, let t = String(validatingUTF8: type) { this._type = t }
            if let domain = domain, let d = String(validatingUTF8: domain) { this._domain = d }
            this.isPublishing = false
            this.lastError = Int(err)
            this.finished()
        }, this))
        guard lastError == kDNSServiceErr_NoError else {
            delegate?.netService(self, didNotPublish: errorDictionary)
