Skip to content

Commit

Permalink
Merge pull request #398 from vibe-d/improve_task_error_logging
Browse files Browse the repository at this point in the history
Log Throwable.toString() instead of just Throwable.msg/info
  • Loading branch information
l-kramer authored Apr 6, 2024
2 parents 553ed5c + 274588c commit 0bfc214
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 0bfc214

Please sign in to comment.