On Friday, 2 October 2015 at 12:18:36 UTC, Dmitri wrote:
On Friday, 2 October 2015 at 11:44:21 UTC, steven kladitis wrote:
C:\d\examples>pb2
=>main's first line
  =>makeOmelet's first line
    =>prepareAll's first line
      =>prepareEggs's first line
object.Exception@pb2.d(64): Cannot take -8 eggs from the fridge
----------------
0x00402252
0x0040512F
0x00405043
0x00403E48
0x7600338A in BaseThreadInitThunk
0x77A497F2 in RtlInitializeExceptionChain
0x77A497C5 in RtlInitializeExceptionChain


----- I always see the info at the bottom. Is this normal. I was thinkig I should only the the exception message itself.
---  this is windows 7 32 bit.

that would the stack of the thread leading up to the exception. I think you get that if you dump the exception object itself (not just the message).

-------------- code is below
import std.stdio;
import std.string;

void indent(in int level)
{
    foreach (i; 0 .. level * 2)
    {
        write(' ');
    }
}
void entering(in char[] functionName, in int level)
{
    indent(level);
    writeln("=>", functionName, "'s first line");
}
void exiting(in char[] functionName, in int level)
{
    indent(level);
    writeln("<=", functionName, "'s last line");
}
void main()
{
    entering("main", 0);
    makeOmelet(-8);
    eatOmelet();
    exiting("main", 0);
}
void makeOmelet(int eggCount)
{
    entering("makeOmelet", 1);
    prepareAll(eggCount);
    cookEggs();
    cleanAll();
    exiting("makeOmelet", 1);
}
void eatOmelet()
{
    entering("eatOmelet", 1);
    exiting("eatOmelet", 1);
}
void prepareAll(int eggCount)
{
    entering("prepareAll", 2);
    prepareEggs(eggCount);
    prepareButter();
    preparePan();
    exiting("prepareAll", 2);
}
void cookEggs()
{
    entering("cookEggs", 2);
    exiting("cookEggs", 2);
}
void cleanAll()
{
    entering("cleanAll", 2);
    exiting("cleanAll", 2);
}
void prepareEggs(int count)
{
    entering("prepareEggs", 3);
    if (count < 1)
    {
        throw new Exception(
format("Cannot take %s eggs from the fridge", count));
    }
    exiting("prepareEggs", 3);
}
void prepareButter()
{
    entering("prepareButter", 3);
    exiting("prepareButter", 3);
}
void preparePan()
{
    entering("preparePan", 3);
    exiting("preparePan", 3);
}

Reply via email to