C++ Logo

std-proposals

Advanced search

Re: Stacktrace from exception

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Wed, 28 Apr 2021 17:57:03 +0100
On Wed, 28 Apr 2021 at 17:06, Ville Voutilainen <ville.voutilainen_at_[hidden]>
wrote:

> On Wed, 28 Apr 2021 at 18:42, Edward Catmur via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> > You're using exceptions in situations where you don't care about the
> stacktrace? Does that mean you're using exceptions as flow control?
>
> No. Current uses of exceptions are such that the exception type and
> its data contain all the information necessary for callers to deal
> with the exception,
> the stacktrace information is irrelevant for that.
>

It is necessary if you need it to be able to investigate the exception, and
thus the caller needs to log it. In that case dealing with the exception
requires having a stacktrace from throw point to handler.

> The way we use exceptions they are encountered rarely, and so the minimal
> overhead of capturing a partial stacktrace on throw (to handler) would be
> entirely acceptable. The more so if there is no heap allocation until
> std::current_exception_stacktrace() or std::current_exception() is called.
>
> Overhead is overhead, there shouldn't be any, if it can be avoided.

Received on 2021-04-28 11:57:16