Browse Source

Formatting: Replace several occurrences of `catch (let ...)` with just `catch`.

Daniel Alm 8 years ago
parent
commit
f814a34949

+ 7 - 7
Examples/EchoXcode/Echo/EchoViewController.swift

@@ -44,7 +44,7 @@ class EchoViewController: NSViewController, NSTextFieldDelegate {
       do {
         try callServer(address: addressField.stringValue,
                        host: "example.com")
-      } catch (let error) {
+      } catch {
         print(error)
       }
     }
@@ -54,7 +54,7 @@ class EchoViewController: NSViewController, NSTextFieldDelegate {
     if nowStreaming {
       do {
         try sendClose()
-      } catch (let error) {
+      } catch {
         print(error)
       }
     }
@@ -66,7 +66,7 @@ class EchoViewController: NSViewController, NSTextFieldDelegate {
     if nowStreaming {
       do {
         try sendClose()
-      } catch (let error) {
+      } catch {
         print(error)
       }
     }
@@ -76,7 +76,7 @@ class EchoViewController: NSViewController, NSTextFieldDelegate {
     if nowStreaming {
       do {
         try sendClose()
-      } catch (let error) {
+      } catch {
         print(error)
       }
     }
@@ -151,7 +151,7 @@ class EchoViewController: NSViewController, NSTextFieldDelegate {
           }
           try receiveExpandMessages()
           displayMessageSent(requestMessage.text)
-        } catch (let error) {
+        } catch {
           self.displayMessageReceived("No message received. \(error)")
         }
       }
@@ -169,7 +169,7 @@ class EchoViewController: NSViewController, NSTextFieldDelegate {
           }
         }
         try sendCollectMessage()
-      } catch (let error) {
+      } catch {
         self.displayMessageReceived("No message received. \(error)")
       }
     } else if callSelectButton.selectedSegment == 3 {
@@ -187,7 +187,7 @@ class EchoViewController: NSViewController, NSTextFieldDelegate {
           }
         }
         try sendUpdateMessage()
-      } catch (let error) {
+      } catch {
         self.displayMessageReceived("No message received. \(error)")
       }
     }

+ 1 - 1
Examples/Google/NaturalLanguage/Sources/main.swift

@@ -55,7 +55,7 @@ if let provider = DefaultTokenProvider(scopes: scopes) {
       do {
         let result = try service.annotatetext(request)
         print("\(result)")
-      } catch (let error) {
+      } catch {
         print("ERROR: \(error)")
       }
     }

+ 4 - 4
Examples/SimpleXcode/Simple/Document.swift

@@ -181,8 +181,8 @@ class Document: NSDocument {
               }
             }
           }
-        } catch (let callError) {
-          Swift.print("call error \(callError)")
+        } catch {
+          Swift.print("call error \(error)")
         }
         self.log("------------------------------")
         sleep(1)
@@ -241,8 +241,8 @@ class Document: NSDocument {
                                         trailingMetadata: trailingMetadataToSend)
 
         self.log("------------------------------")
-      } catch (let callError) {
-        Swift.print("call error \(callError)")
+      } catch {
+        Swift.print("call error \(error)")
       }
     }
 

+ 2 - 2
Sources/Examples/Echo/EchoProvider.swift

@@ -48,7 +48,7 @@ class EchoProvider: Echo_EchoProvider {
         guard let request = try session.receive()
           else { break }  // End of stream
         parts.append(request.text)
-      } catch (let error) {
+      } catch {
         print("\(error)")
       }
     }
@@ -72,7 +72,7 @@ class EchoProvider: Echo_EchoProvider {
             print("update error: \(error)")
           }
         }
-      } catch (let error) {
+      } catch {
         print("\(error)")
         break
       }

+ 2 - 2
Sources/Examples/Simple/main.swift

@@ -110,8 +110,8 @@ func server() throws {
                                       trailingMetadata: trailingMetadataToSend)
 
       print("------------------------------")
-    } catch (let callError) {
-      Swift.print("call error \(callError)")
+    } catch {
+      Swift.print("call error \(error)")
     }
   }
 

+ 2 - 2
Sources/SwiftGRPC/Core/Call.swift

@@ -188,8 +188,8 @@ public class Call {
               let (nextMessage, nextCompletionHandler) = self.messageQueue.removeFirst()
               do {
                 try self.sendWithoutBlocking(data: nextMessage, completion: nextCompletionHandler)
-              } catch (let callError) {
-                nextCompletionHandler?(callError)
+              } catch {
+                nextCompletionHandler?(error)
               }
             } else {
               // otherwise, we are finished writing

+ 2 - 2
Sources/SwiftGRPC/Core/Server.swift

@@ -109,8 +109,8 @@ public class Server {
           } else if event.type == .queueShutdown {
             running = false
           }
-        } catch (let callError) {
-          print("server call error: \(callError)")
+        } catch {
+          print("server call error: \(error)")
           running = false
         }
       }

+ 1 - 1
Sources/SwiftGRPC/Runtime/ServerSessionBidirectionalStreaming.swift

@@ -47,7 +47,7 @@ open class ServerSessionBidirectionalStreamingBase<InputType: Message, OutputTyp
       queue.async {
         do {
           try self.providerBlock(self)
-        } catch (let error) {
+        } catch {
           print("error \(error)")
         }
       }

+ 1 - 1
Sources/SwiftGRPC/Runtime/ServerSessionClientStreaming.swift

@@ -43,7 +43,7 @@ open class ServerSessionClientStreamingBase<InputType: Message, OutputType: Mess
       queue.async {
         do {
           try self.providerBlock(self)
-        } catch (let error) {
+        } catch {
           print("error \(error)")
         }
       }

+ 2 - 2
Sources/SwiftGRPC/Runtime/ServerSessionServerStreaming.swift

@@ -48,11 +48,11 @@ open class ServerSessionServerStreamingBase<InputType: Message, OutputType: Mess
                                           statusMessage: self.statusMessage,
                                           trailingMetadata: self.trailingMetadata,
                                           completion: nil)
-            } catch (let error) {
+            } catch {
               print("error: \(error)")
             }
           }
-        } catch (let error) {
+        } catch {
           print("error: \(error)")
         }
       }

+ 1 - 1
Sources/SwiftGRPC/Runtime/ServiceServer.swift

@@ -73,7 +73,7 @@ open class ServiceServer {
                                  statusMessage: "unknown method " + unwrappedMethod,
                                  trailingMetadata: Metadata())
         }
-      } catch (let error) {
+      } catch {
         print("Server error: \(error)")
       }
     }

+ 1 - 1
Sources/protoc-gen-swiftgrpc/main.swift

@@ -124,6 +124,6 @@ func main() throws {
 
 do {
   try main()
-} catch (let error) {
+} catch {
   Log("ERROR: \(error)")
 }

+ 3 - 3
Tests/SwiftGRPCTests/GRPCTests.swift

@@ -99,14 +99,14 @@ func runTest(useSSL: Bool) {
   // start the server
   do {
     serverRunningSemaphore = try runServer(server: server)
-  } catch (let error) {
+  } catch {
     XCTFail("server error \(error)")
   }
 
   // run the client
   do {
     try runClient(useSSL: useSSL)
-  } catch (let error) {
+  } catch {
     XCTFail("client error \(error)")
   }
 
@@ -300,7 +300,7 @@ func runServer(server: Server) throws -> DispatchSemaphore {
       }
 
       requestCount += 1
-    } catch (let error) {
+    } catch {
       XCTFail("error \(error)")
     }
   }