Skip to content

Commit

Permalink
[?] Use error information in THROW expression on failed connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
korydraughn committed Jul 22, 2024
1 parent 0e7a8f3 commit d6d5376
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/core/src/client_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ namespace irods::experimental
{
only_connect(_host, _port, _username);

if (clientLogin(conn_.get()) != 0) {
if (const auto ec = clientLogin(conn_.get()); ec < 0) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
THROW(AUTHENTICATION_ERROR, "Client login error");
THROW(ec, "Client login error");
}
} // connect_and_login

Expand All @@ -169,9 +169,9 @@ namespace irods::experimental
{
only_connect(_host, _port, _proxy_username, _username);

if (clientLogin(conn_.get()) != 0) {
if (const auto ec = clientLogin(conn_.get()); ec < 0) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
THROW(AUTHENTICATION_ERROR, "Client login error");
THROW(ec, "Client login error");
}
} // connect_and_login

Expand All @@ -183,6 +183,11 @@ namespace irods::experimental
conn_.reset(
rcConnect(_host.c_str(), _port, _username.name().c_str(), _username.zone().c_str(), NO_RECONN, &error));

if (error.status < 0) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
THROW(error.status, error.msg);
}

if (!conn_) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
THROW(USER_SOCK_CONNECT_ERR, "Connect error");
Expand All @@ -205,6 +210,11 @@ namespace irods::experimental
1,
NO_RECONN));

if (error.status < 0) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
THROW(error.status, error.msg);
}

if (!conn_) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
THROW(USER_SOCK_CONNECT_ERR, "Connect error");
Expand Down

0 comments on commit d6d5376

Please sign in to comment.