Re: Throw an exception but "hide" the top frame?

2014-12-24 Thread Sean Kelly via Digitalmars-d-learn
The backtrace code has a parameter that lets you tell it how many leading frames you want it to skip when generating the result. This is to get out of the Throwable ctor code itself, but it wouldn't be hard to bump this by one or two if you need it to.

Re: Throw an exception but "hide" the top frame?

2014-12-24 Thread aldanor via Digitalmars-d-learn
On Wednesday, 24 December 2014 at 14:11:37 UTC, Adam D. Ruppe wrote: auto check(alias func)(int x, string file = __FILE__, size_t line = __LINE__) { /* snip */ throw new Exception("%d < 0".format(result), file, line); // L10 Thanks! I guess that's what my confusion was partially ab

Re: Throw an exception but "hide" the top frame?

2014-12-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 24 December 2014 at 14:04:51 UTC, aldanor wrote: auto check(string file = __FILE__, int line = __LINE__)(int x) { You can just do regular params (most the time), don't have to be template params. My last email shows that too. Then it doesn't make new templates on each us

Re: Throw an exception but "hide" the top frame?

2014-12-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 24 December 2014 at 13:39:00 UTC, aldanor wrote: (especially when many such functions have been wrapped). Is it somehow possible to throw an exception "from the parent frame" so the backtrace would never drop into the template body? Since this is just passed as arguments to the

Re: Throw an exception but "hide" the top frame?

2014-12-24 Thread ketmar via Digitalmars-d-learn
"has to generate new parameterized function", of course. sorry. signature.asc Description: PGP signature

Re: Throw an exception but "hide" the top frame?

2014-12-24 Thread ketmar via Digitalmars-d-learn
On Wed, 24 Dec 2014 14:04:50 + aldanor via Digitalmars-d-learn wrote: > On Wednesday, 24 December 2014 at 13:48:26 UTC, ketmar via > Digitalmars-d-learn wrote: > > the `object.Exception@wrap.d` is not a backtrace result, this > > is the > > result of Exception class constructor: > > > > t

Re: Throw an exception but "hide" the top frame?

2014-12-24 Thread aldanor via Digitalmars-d-learn
On Wednesday, 24 December 2014 at 13:48:26 UTC, ketmar via Digitalmars-d-learn wrote: the `object.Exception@wrap.d` is not a backtrace result, this is the result of Exception class constructor: this (string msg, string file=__FILE__, usize line=__LINE__, Throwable next=null) it registering

Re: Throw an exception but "hide" the top frame?

2014-12-24 Thread ketmar via Digitalmars-d-learn
On Wed, 24 Dec 2014 13:38:59 + aldanor via Digitalmars-d-learn wrote: > Imagine there's a template that wraps arbitrary functions and may > throw exceptions depending on their returned values (see a > simplified example below). However, if an exception occurs, the > backtrace is pointing i

Throw an exception but "hide" the top frame?

2014-12-24 Thread aldanor via Digitalmars-d-learn
Imagine there's a template that wraps arbitrary functions and may throw exceptions depending on their returned values (see a simplified example below). However, if an exception occurs, the backtrace is pointing inside the template which is not helpful at all (especially when many such functions