Skip to content

Commit

Permalink
exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-bhargava committed Aug 3, 2020
1 parent e0d7457 commit 322e5c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sdk/include/opentelemetry/sdk/metrics/instrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ inline void print_value(std::stringstream &ss,
ss << '"';
break;
default:
#if __EXCEPTIONS
throw std::invalid_argument("Labels must be strings");
#else
std::terminate();
#endif
break;
}
};
Expand Down
8 changes: 8 additions & 0 deletions sdk/include/opentelemetry/sdk/metrics/sync_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ class BoundCounter final : public BoundSynchronousInstrument<T>, public metrics_
this->mu_.lock();
if (value < 0)
{
#if __EXCEPTIONS
throw std::invalid_argument("Counter instrument updates must be non-negative.");
#else
std::terminate();
#endif
}
else
{
Expand Down Expand Up @@ -118,7 +122,11 @@ class Counter final : public SynchronousInstrument<T>, public metrics_api::Count
this->mu_.lock();
if (value < 0)
{
#if __EXCEPTIONS
throw std::invalid_argument("Counter instrument updates must be non-negative.");
#else
std::terminate();
#endif
}
else
{
Expand Down

0 comments on commit 322e5c8

Please sign in to comment.