problem with exceptions

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 2 06:53:16 PDT 2015


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 at 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.

The info at the bottom is the backtrace. Compiling with -g should 
make it readable (with function names and such).
```
void bar(int i) {
     if(i > 10)
         throw new Exception("i is too large!!");
}

void main() {
     bar(12);
}
```

dmd -g foo

object.Exception at foo.d(14): i is too large!!
----------------
0x00402055 in void foo.bar(int) at 
C:\LearningD\Chapter05\foo.d(15)
0x00402065 in _Dmain at C:\LearningD\Chapter05\foo.d(19)
0x00402916 in 
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x004028EB in void rt.dmain2._d_run_main(int, char**, extern (C) 
int function(char[][])*).runAll()
0x004027FF in _d_run_main
0x004024F4 in main
0x00419F51 in mainCRTStartup
0x75803744 in BaseThreadInitThunk
0x770EA064 in RtlSetCurrentTransaction
0x770EA02F in RtlSetCurrentTransaction



More information about the Digitalmars-d-learn mailing list