mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-08-17 16:57:05 +00:00
change assertions to print the error in release builds
this should make it easier to debug crashes in the server remotely in release builds when sentry is down.
This commit is contained in:
parent
24c98eb2b2
commit
e638c25f70
@ -58,16 +58,17 @@ inline void _assert([[maybe_unused]] const char* file, [[maybe_unused]] const ch
|
|||||||
#define beammp_assert(cond) _assert(__FILE__, __func__, __LINE__, #cond, (cond))
|
#define beammp_assert(cond) _assert(__FILE__, __func__, __LINE__, #cond, (cond))
|
||||||
#define beammp_assert_not_reachable() _assert(__FILE__, __func__, __LINE__, "reached unreachable code", false)
|
#define beammp_assert_not_reachable() _assert(__FILE__, __func__, __LINE__, "reached unreachable code", false)
|
||||||
#else
|
#else
|
||||||
// In release build, these macros turn into NOPs. The compiler will optimize these out.
|
#define beammp_assert(cond) \
|
||||||
#define beammp_assert(cond) \
|
do { \
|
||||||
do { \
|
bool result = (cond); \
|
||||||
bool result = (cond); \
|
if (!result) { \
|
||||||
if (!result) { \
|
beammp_errorf("Assertion failed in '{}:{}': {}.", __func__, _line, #cond); \
|
||||||
Sentry.LogAssert(#cond, _file_basename, _line, __func__); \
|
Sentry.LogAssert(#cond, _file_basename, _line, __func__); \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
#define beammp_assert_not_reachable() \
|
#define beammp_assert_not_reachable() \
|
||||||
do { \
|
do { \
|
||||||
Sentry.LogAssert("code is unreachable", _file_basename, _line, __func__); \
|
beammp_errorf("Assertion failed in '{}:{}': Unreachable code reached. This may result in a crash or undefined state of the program.", __func__, _line); \
|
||||||
|
Sentry.LogAssert("code is unreachable", _file_basename, _line, __func__); \
|
||||||
} while (false)
|
} while (false)
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user