X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_rpc_json.cpp;h=0502c7cbdcb4b13dfef60f0f589fcb665655a709;hb=e9d1efc1ae29ee86b3c2a42bf56531afac7add6d;hp=563ca627ca025517de77fe2c7c232091259763eb;hpb=6f59e7a0a0780da88bad9ba3c28ca32680cfec37;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_rpc_json.cpp b/src/modules/m_rpc_json.cpp index 563ca627c..0502c7cbd 100644 --- a/src/modules/m_rpc_json.cpp +++ b/src/modules/m_rpc_json.cpp @@ -105,37 +105,6 @@ class ModuleRpcJson : public Module } }; -static void -unreachable_internal (char const *file, int line, char const *function) -{ - char buf[1024]; - snprintf (buf, 1024, "%s (%d) [%s] critical: Unreachable line reached.", - file, line, function); - - throw std::runtime_error (buf); -} - -static void -throw_unless_internal (char const *file, int line, char const *function, char const *condition) -{ - char buf[1024]; - snprintf (buf, 1024, "%s (%d) [%s] critical: Assertion `%s' failed.", - file, line, function, condition); - - throw std::runtime_error (buf); -} - -static void -throw_msg_unless_internal (char const *file, int line, char const *function, char const *message) -{ - char buf[1024]; - snprintf (buf, 1024, "%s (%d) [%s] critical: %s.", - file, line, function, message); - - throw std::runtime_error (buf); -} - - namespace json { ValueIteratorBase::ValueIteratorBase () @@ -887,6 +856,10 @@ namespace json throw std::runtime_error (buf); } + +#define throw_unreachable unreachable_internal (__FILE__, __LINE__, CURFUNC) +#define throw_unless(condition) if (!expect_false (condition)) throw_unless_internal (__FILE__, __LINE__, CURFUNC, #condition) +#define throw_msg_unless(condition, message) if (!expect_false (condition)) throw_msg_unless_internal (__FILE__, __LINE__, CURFUNC, message) const Value Value::null; const int Value::minInt = int (~ (unsigned (-1)/2));