From 1f692fba828462ba6d24d607a6b299a7fe8865af Mon Sep 17 00:00:00 2001 From: George Barnett Date: Thu, 27 Mar 2025 15:59:55 +0000 Subject: [PATCH] Improve error message when client is run when shutdown Motivation: GRPCClient can throw an error when run is called more than once or if run is called after it has been shutdown. Normally this would happen if a user caller 'run()' more than once, but can also happen if 'withGRPCClient' is called and the client is never used and the body returns quickly. Modifications: - Improve the error message Result: Better error message. --- Sources/GRPCCore/GRPCClient.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/GRPCCore/GRPCClient.swift b/Sources/GRPCCore/GRPCClient.swift index b3093f8b1..ffb6911ae 100644 --- a/Sources/GRPCCore/GRPCClient.swift +++ b/Sources/GRPCCore/GRPCClient.swift @@ -89,7 +89,11 @@ public final class GRPCClient: Sendable { case .stopping, .stopped: throw RuntimeError( code: .clientIsStopped, - message: "The client has stopped and can only be started once." + message: """ + Can't call 'runConnections()' as the client is stopped (or is stopping). \ + This can happen if the you call 'runConnections()' after shutting the \ + client down or if you used 'withGRPCClient' with an empty body. + """ ) } }