Skip to content

Commit

Permalink
Log Throwable.toString() instead of just Throwable.msg/info.
Browse files Browse the repository at this point in the history
This also prints the file and line number, making it more useful in cases where the stack trace is not usable.
  • Loading branch information
s-ludwig committed Apr 6, 2024
1 parent 553ed5c commit 274588c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions source/vibe/core/task.d
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,7 @@ final package class TaskFiber : Fiber {
GetUserObjectInformationA(GetProcessWindowStation(), UOI_FLAGS, &wsf, wsf.sizeof, null);
if (wsf.dwFlags & WSF_VISIBLE) {
FixedAppender!(char[], 2048, BufferOverflowMode.ignore) msg = void;
msg.formattedWrite("%s: %s\r\n\r\n", th.classinfo.name, th.msg);
foreach (ln; th.info)
msg.formattedWrite("%s\r\n", ln);
msg.formattedWrite("%s: %s", th.classinfo.name, th);
msg.put('\0');
msg.data[msg.data.length-1] = '\0';
MessageBoxA(null, msg.data.ptr, "FATAL: Uncaught exception in task fiber", MB_ICONERROR);
Expand All @@ -440,11 +438,11 @@ final package class TaskFiber : Fiber {
}

if (GC.inFinalizer) {
stderr.writeln("TaskFiber getting terminated due to an uncaught ", th.classinfo.name, ": ", th.msg);
foreach (ln; th.info) stderr.writeln(ln);
stderr.write("TaskFiber getting terminated due to an uncaught ", th.classinfo.name, ": ");
th.toString((str) { stderr.write(str); });
stderr.writeln();
} else {
logFatal("TaskFiber getting terminated due to an uncaught %s: %s", th.classinfo.name, th.msg);
foreach (ln; th.info) logFatal("%s", ln);
logFatal("TaskFiber getting terminated due to an uncaught %s: %s", th.classinfo.name, th);
}
} catch (Exception e) {
if (GC.inFinalizer) {
Expand Down

0 comments on commit 274588c

Please sign in to comment.