Skip to content

Commit caddc57

Browse files
committed
CR comments
1 parent 69eea20 commit caddc57

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/viam/sdk/rpc/dial.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,19 @@ std::shared_ptr<ViamChannel> ViamChannel::dial_initial(
123123
}
124124
opts.set_timeout(opts.initial_connection_attempt_timeout());
125125

126+
std::exception exception;
126127
while (attempts_remaining > 0) {
127128
try {
128129
auto connection = dial(uri, opts);
129130
opts.set_timeout(timeout);
130131
return connection;
131-
} catch (const std::exception&) {
132+
} catch (const std::exception& e) {
132133
attempts_remaining -= 1;
134+
exception = e;
133135
}
134136
}
135137

136-
throw Exception(ErrorCondition::k_connection, "Unable to establish connection");
138+
throw Exception(ErrorCondition::k_connection, exception.what());
137139
}
138140

139141
std::shared_ptr<ViamChannel> ViamChannel::dial(const char* uri,

src/viam/sdk/rpc/dial.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,19 @@ class ViamChannel {
1717
void close();
1818
ViamChannel(std::shared_ptr<GrpcChannel> channel, const char* path, void* runtime);
1919

20+
/// @brief Connects to a robot at the given URI address, using the provided dial options (or
21+
/// default options is none are provided). Ignores initial connection options specifying
22+
/// how many times to attempt to connect and with what timeout.
23+
/// In general, use of this method is discouraged. `RobotClient::at_address(...)` is the
24+
/// preferred method to connect to a robot, and creates the channel itself.
2025
static std::shared_ptr<ViamChannel> dial(const char* uri,
2126
const boost::optional<DialOptions>& options);
2227

23-
// Specifies that this dial is an initial connection attempt and that initial connection options
24-
// should be used.
28+
// @brief Dials to a robot at the given URI address, using the provided dial options (or default
29+
// options is none are provided). Additionally specifies that this dial is an initial connection
30+
// attempt and so uses the initial connection options.
31+
/// In general, use of this method is discouraged. `RobotClient::at_address(...)` is the
32+
/// preferred method to connect to a robot, and creates the channel itself.
2533
static std::shared_ptr<ViamChannel> dial_initial(const char* uri,
2634
const boost::optional<DialOptions>& options);
2735

0 commit comments

Comments
 (0)