Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
updated all internal_exceptions to have errno and a reason
Browse files Browse the repository at this point in the history
  • Loading branch information
rontana committed Sep 17, 2014
1 parent 950b0d9 commit 2d7d9e7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/riemannpp/attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ attribute::set(const std::string& key, const std::string& value) {
int result = riemann_attribute_set(d_attribute.get(),
key.c_str(), value.c_str());
if (-1 == result) {
throw internal_exception();
throw internal_exception(errno, "failed to set attribute for key: " + key + ", with value: " + value);
}
}

void
attribute::set_key(const std::string& key) {
int result = riemann_attribute_set_key(d_attribute.get(), key.c_str());
if (-1 == result) {
throw internal_exception();
throw internal_exception(errno, "failed to set attribute key " + key);
}
}

void
attribute::set_value(const std::string& value) {
int result = riemann_attribute_set_value(d_attribute.get(), value.c_str());
if (-1 == result) {
throw internal_exception();
throw internal_exception(errno, "failed to set attribute value " + value);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/riemannpp/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ client::client(client_type type, const std::string& host, int port) {
d_client = riemann_client_create(riemann_client_type_t(type),
host.c_str(), port);
if (!d_client) {
throw internal_exception("failed to create riemann client");
throw internal_exception(errno, "failed to create riemann client");
}
}

Expand Down Expand Up @@ -69,23 +69,23 @@ client::connect(client_type type, const std::string& host, int port) {
message += host;
message += ":";
message += std::to_string(port);
throw internal_exception(message);
throw internal_exception(errno, message);
}
}

void
client::disconnect() {
int result = riemann_client_disconnect(d_client);
if (0 != result) {
throw internal_exception("failed to disconnect client");
throw internal_exception(errno, "failed to disconnect client");
}
}

void
client::send(message&& m) {
int result = riemann_client_send_message(d_client, m.release());
if (0 != result) {
throw internal_exception("failed to send message");
throw internal_exception(errno, "failed to send message");
}
}

Expand All @@ -104,7 +104,7 @@ void
client::send_oneshot(message&& m) {
int result = riemann_client_send_message_oneshot(d_client, m.release());
if (0 != result) {
throw internal_exception("failed to send oneshot message");
throw internal_exception(errno, "failed to send oneshot message");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/riemannpp/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void
event::tag_add(const std::string& tag) {
int result = riemann_event_tag_add(d_event.get(), tag.c_str());
if (0 != result) {
throw internal_exception();
throw internal_exception(errno, "failed to add event tag: " + tag);
}
}

Expand All @@ -75,7 +75,7 @@ void
event::attribute_add(attribute&& a) {
int result = riemann_event_attribute_add(d_event.get(), a.release());
if (0 != result) {
throw internal_exception();
throw internal_exception(errno, "failed to add event attribute");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/riemannpp/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace riemannpp {
void event::set(const event_field field, const T& value) {
int result = riemann_event_set(d_event.get(), field, value, RIEMANN_EVENT_FIELD_NONE);
if (0 != result) {
throw internal_exception();
throw internal_exception(errno, "failed to set event field");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/riemannpp/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void
message::set_event(event& e) {
int result = riemann_message_set_events(d_message.get(), e.release(), nullptr);
if (0 != result) {
throw internal_exception();
throw internal_exception(errno, "failed to set event");
}
}

Expand All @@ -76,7 +76,7 @@ void
message::set_query(query& q) {
int result = riemann_message_set_query(d_message.get(), q.release());
if (0 != result) {
throw internal_exception();
throw internal_exception(errno, "failed to set query");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/riemannpp/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void
query::set_string(const std::string& query) {
int result = riemann_query_set_string(d_query.get(), query.c_str());
if (0 != result) {
throw internal_exception();
throw internal_exception(errno, "failed to set query string: " + query);
}
}

Expand Down

0 comments on commit 2d7d9e7

Please sign in to comment.