improve messaging of assert caused by precondition violation
This commit is contained in:
@@ -215,7 +215,7 @@ boost::detail::atomic_count assert_counter(0);
|
||||
#endif
|
||||
|
||||
TORRENT_EXPORT void assert_fail(char const* expr, int line, char const* file
|
||||
, char const* function, char const* value)
|
||||
, char const* function, char const* value, int kind)
|
||||
{
|
||||
#if TORRENT_PRODUCTION_ASSERTS
|
||||
// no need to flood the assert log with infinite number of asserts
|
||||
@@ -231,11 +231,20 @@ TORRENT_EXPORT void assert_fail(char const* expr, int line, char const* file
|
||||
stack[0] = '\0';
|
||||
print_backtrace(stack, sizeof(stack), 0);
|
||||
|
||||
fprintf(out, "assertion failed. Please file a bugreport at "
|
||||
char const* message = "assertion failed. Please file a bugreport at "
|
||||
"http://code.google.com/p/libtorrent/issues\n"
|
||||
"Please include the following information:\n\n"
|
||||
"version: " LIBTORRENT_VERSION "\n"
|
||||
"%s\n"
|
||||
LIBTORRENT_REVISION "\n";
|
||||
|
||||
switch (kind)
|
||||
{
|
||||
case 1:
|
||||
message = "A precondition of a libtorrent function has been violated.\n"
|
||||
"This indicates a bug in the client application using libtorrent\n";
|
||||
}
|
||||
|
||||
fprintf(out, "%s\n"
|
||||
"file: '%s'\n"
|
||||
"line: %d\n"
|
||||
"function: %s\n"
|
||||
@@ -243,7 +252,7 @@ TORRENT_EXPORT void assert_fail(char const* expr, int line, char const* file
|
||||
"%s%s\n"
|
||||
"stack:\n"
|
||||
"%s\n"
|
||||
, LIBTORRENT_REVISION, file, line, function, expr
|
||||
, message, file, line, function, expr
|
||||
, value ? value : "", value ? "\n" : ""
|
||||
, stack);
|
||||
|
||||
@@ -260,7 +269,8 @@ TORRENT_EXPORT void assert_fail(char const* expr, int line, char const* file
|
||||
|
||||
#else
|
||||
|
||||
TORRENT_EXPORT void assert_fail(char const* expr, int line, char const* file, char const* function) {}
|
||||
TORRENT_EXPORT void assert_fail(char const* expr, int line, char const* file
|
||||
, char const* function, char const* value, int kind) {}
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user