Skip to content

Commit

Permalink
replace throw with a macro.
Browse files Browse the repository at this point in the history
replace throw with a macro so that exception messages can be handled by the application. kazuho#148
  • Loading branch information
shun126 authored Jul 10, 2022
1 parent 111c9be commit 02bbd9e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions picojson.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@ extern "C" {
}
#endif

#ifndef PICOJSON_THROW
#define PICOJSON_THROW(e, m) throw e(m)
#endif

#ifndef PICOJSON_ASSERT
#define PICOJSON_ASSERT(e) \
do { \
if (!(e)) \
throw std::runtime_error(#e); \
PICOJSON_THROW(std::runtime_error(#e)); \
} while (0)
#endif

Expand Down Expand Up @@ -251,8 +255,8 @@ inline value::value(double n) : type_(number_type), u_() {
#else
isnan(n) || isinf(n)
#endif
) {
throw std::overflow_error("");
) {
PICOJSON_THROW(std::overflow_error(""));
}
u_.number_ = n;
}
Expand Down

0 comments on commit 02bbd9e

Please sign in to comment.