boost::errinfo_stacktrace?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

boost::errinfo_stacktrace?

Boost - Users mailing list
Since the arrival of Boost.Stacktrace, I've been expecting a conventional boost::errinfo_stacktrace helper to join the suite of other boost::errinfo_mumble helpers. Is there a PR open with that?

--
NAT LINDEN | Senior Software Engineer | Real Life: Nat Goodspeed LINDEN LAB | Create Virtual Experiences

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost::errinfo_stacktrace?

Boost - Users mailing list
On Mon, 18 Nov 2019 at 23:55, Nat Goodspeed via Boost-users
<[hidden email]> wrote:
>
> Since the arrival of Boost.Stacktrace, I've been expecting a conventional boost::errinfo_stacktrace helper to join the suite of other boost::errinfo_mumble helpers. Is there a PR open with that?

There's already support for it.
https://www.boost.org/doc/libs/1_65_1/doc/html/stacktrace/getting_started.html#stacktrace.getting_started.exceptions_with_stacktrace

I never got the point of boost.exception though.
If you want exception info, just hook into your exception runtime and
get all of them, instead of just the ones thrown with the boost
exception magic.

Also you don't really need to do that for every throw, you only need
to do it if the throw is not matched to any catch or if the catch is a
special one.
There is special compiler magic that allows you to run code before
unwinding for specific catch sites.

What I personally do is that I go the extra mile: I generate a core
file, which is more useful than a stack trace.
That's a lot more expensive than just getting the stack though.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost::errinfo_stacktrace?

Boost - Users mailing list
On Wed, Nov 20, 2019 at 2:50 AM Mathias Gaunard via Boost-users <[hidden email]> wrote:
On Mon, 18 Nov 2019 at 23:55, Nat Goodspeed via Boost-users
<[hidden email]> wrote:
>
> Since the arrival of Boost.Stacktrace, I've been expecting a conventional boost::errinfo_stacktrace helper to join the suite of other boost::errinfo_mumble helpers. Is there a PR open with that?

There's already support for it.
https://www.boost.org/doc/libs/1_65_1/doc/html/stacktrace/getting_started.html#stacktrace.getting_started.exceptions_with_stacktrace

I never got the point of boost.exception though.
If you want exception info, just hook into your exception runtime and
get all of them, instead of just the ones thrown with the boost
exception magic.

The point of Boost Exception is to augment exceptions in flight regardless of their exact type. At the point of the throw, you don't typically have all relevant information to put in the exception object, for example when reporting a file read error you don't have the file name available. Boost Exception allows you to add file names and anything else later on.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost::errinfo_stacktrace?

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
On Mon, Nov 18, 2019 at 3:57 PM Nat Goodspeed via Boost-users <[hidden email]> wrote:
Since the arrival of Boost.Stacktrace, I've been expecting a conventional boost::errinfo_stacktrace helper to join the suite of other boost::errinfo_mumble helpers. Is there a PR open with that?

I don't think there is. I'm going to add this, it seems a good idea. FYI I recommend using LEAF instead of Boost Exception, though it isn't an official Boost lib (yet). It does everything Boost Exception can do, better.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost::errinfo_stacktrace?

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
On Wed, 20 Nov 2019 at 20:13, Emil Dotchevski via Boost-users
<[hidden email]> wrote:

>
> On Wed, Nov 20, 2019 at 2:50 AM Mathias Gaunard via Boost-users <[hidden email]> wrote:
>>
>> On Mon, 18 Nov 2019 at 23:55, Nat Goodspeed via Boost-users
>> <[hidden email]> wrote:
>> >
>> > Since the arrival of Boost.Stacktrace, I've been expecting a conventional boost::errinfo_stacktrace helper to join the suite of other boost::errinfo_mumble helpers. Is there a PR open with that?
>>
>> There's already support for it.
>> https://www.boost.org/doc/libs/1_65_1/doc/html/stacktrace/getting_started.html#stacktrace.getting_started.exceptions_with_stacktrace
>>
>> I never got the point of boost.exception though.
>> If you want exception info, just hook into your exception runtime and
>> get all of them, instead of just the ones thrown with the boost
>> exception magic.
>
>
> The point of Boost Exception is to augment exceptions in flight regardless of their exact type. At the point of the throw, you don't typically have all relevant information to put in the exception object, for example when reporting a file read error you don't have the file name available. Boost Exception allows you to add file names and anything else later on.

In practice most uses I have ever seen are just augmenting the
exception at the throw site with a subset of what a stack trace
provides.

In any case catching and rethrowing exceptions at every layer to add
context information as it bubbles up is not really an idiom I would
recommend.
Not only is quite ugly and complexifies control flow, it's also
inefficient and leads to a poor experience when debugging.

It is a better idea to use normal control flow for this.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost::errinfo_stacktrace?

Boost - Users mailing list
On 21/11/2019 09:58, Mathias Gaunard wrote:
> In any case catching and rethrowing exceptions at every layer to add
> context information as it bubbles up is not really an idiom I would
> recommend.
> Not only is quite ugly and complexifies control flow, it's also
> inefficient and leads to a poor experience when debugging.

I think it works reasonably well, without too much ugliness.

It's a bit better in the .NET languages, since they adopted the idea of
nested exceptions from the start -- at each catch site, you can choose
whether to add additional details to the existing exception and rethrow
it (although this is rarely done since it typically isn't visible in the
string output), to throw another exception with the original nested
within (most common), or to throw another exception without the original
(rarer, but occasionally appropriate).

While C++ now has the ability to do nested exceptions as well, the
plumbing required to actually deal with them (and to extract and log
information) is still pretty terrible.  And most existing code will
neither nest exceptions nor unpack them.

Granted, it can be a little annoying to debug if you have it set to
break on all exceptions (rather than just uncaught ones), but even so,
exceptions should be rare and following it up the call chain can be
useful in itself, so it's not all that poor an experience.

Usually the only time exceptions cause a poor debugging experience is
when code is using them incorrectly (as control flow, not for
exceptional cases; which often leads to try-catch-ignore anti-patterns).

> It is a better idea to use normal control flow for this.

How would you use normal control flow for that example?  (Failure to
parse at a low level that doesn't know the filename, and the higher
level does know the filename.)
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users