Kaynağa Gözat

Remove unnecessary print() calls, properly try calls to sendClose in Echo view controller.

Tim Burks 9 yıl önce
ebeveyn
işleme
d874c75fb3

+ 2 - 4
Examples/Echo/Swift/Generated/echo.client.pb.swift

@@ -176,14 +176,12 @@ public class Echo_EchoCollectCall {
         done.signal()
         done.unlock()
       }
-      try call.close(completion:{
-        print("closed")
-      })
+      try call.close(completion:{})
       done.lock()
       done.wait()
       done.unlock()
     } catch (let error) {
-      print("ERROR: \(error)")
+      throw error
     }
     if let returnError = returnError {
       throw returnError

+ 9 - 3
Examples/Echo/Swift/Xcode/Echo/EchoViewController.swift

@@ -69,7 +69,9 @@ class EchoViewController : NSViewController, NSTextFieldDelegate {
 
   @IBAction func addressReturnPressed(sender: NSTextField) {
     if (nowStreaming) {
-      if let error = try? self.sendClose() {
+      do {
+        try self.sendClose()
+      } catch (let error) {
         print(error)
       }
     }
@@ -79,7 +81,9 @@ class EchoViewController : NSViewController, NSTextFieldDelegate {
 
   @IBAction func buttonValueChanged(sender: NSSegmentedControl) {
     if (nowStreaming) {
-      if let error = try? self.sendClose() {
+      do {
+        try self.sendClose()
+      } catch (let error) {
         print(error)
       }
     }
@@ -87,7 +91,9 @@ class EchoViewController : NSViewController, NSTextFieldDelegate {
 
   @IBAction func closeButtonPressed(sender: NSButton) {
     if (nowStreaming) {
-      if let error = try? self.sendClose() {
+      do {
+        try self.sendClose()
+      } catch (let error) {
         print(error)
       }
     }

+ 2 - 4
Plugin/swiftgrpc.templates/client-call-clientstreaming.swift

@@ -38,14 +38,12 @@ public class {{ .|call:protoFile,service,method }} {
         done.signal()
         done.unlock()
       }
-      try call.close(completion:{
-        print("closed")
-      })
+      try call.close(completion:{})
       done.lock()
       done.wait()
       done.unlock()
     } catch (let error) {
-      print("ERROR: \(error)")
+      throw error
     }
     if let returnError = returnError {
       throw returnError