Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
fix 2.064 merge issue
Browse files Browse the repository at this point in the history
- The function printThrowable relied on the Throwable.toString(sink)
  overload from #636 which is not available in 2.064.

- Fixed by re-adding the old exception print code.
  • Loading branch information
MartinNowak committed Oct 30, 2013
1 parent 7c396ef commit 567c7af
Showing 1 changed file with 56 additions and 10 deletions.
66 changes: 56 additions & 10 deletions src/rt/dmain2.d
Expand Up @@ -432,23 +432,69 @@ extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc)

private void printThrowable(Throwable t)
{
void sink(const(char)[] buf) nothrow
static void printLocLine(Throwable t)
{
printf("%.*s", cast(int)buf.length, buf.ptr);
if (t.file)
{
console(t.classinfo.name)("@")(t.file)("(")(t.line)(")");
}
else
{
console(t.classinfo.name);
}
console("\n");
}

for (; t; t = t.next)
static void printMsgLine(Throwable t)
{
t.toString(&sink); sink("\n");
if (t.file)
{
console(t.classinfo.name)("@")(t.file)("(")(t.line)(")");
}
else
{
console(t.classinfo.name);
}
if (t.msg)
{
console(": ")(t.msg);
}
console("\n");
}

auto e = cast(Error)t;
if (e is null || e.bypassedException is null) continue;
static void printInfoBlock(Throwable t)
{
if (t.info)
{
console("----------------\n");
foreach (i; t.info)
console(i)("\n");
console("----------------\n");
}
}

sink("=== Bypassed ===\n");
for (auto t2 = e.bypassedException; t2; t2 = t2.next)
Throwable firstWithBypass = null;

for (; t; t = t.next)
{
printMsgLine(t);
printInfoBlock(t);
auto e = cast(Error) t;
if (e && e.bypassedException)
{
t2.toString(&sink); sink("\n");
console("Bypasses ");
printLocLine(e.bypassedException);
if (firstWithBypass is null)
firstWithBypass = t;
}
sink("=== ~Bypassed ===\n");
}
if (firstWithBypass is null)
return;
console("=== Bypassed ===\n");
for (t = firstWithBypass; t; t = t.next)
{
auto e = cast(Error) t;
if (e && e.bypassedException)
printThrowable(e.bypassedException);
}
}

0 comments on commit 567c7af

Please sign in to comment.