C++ Logo

std-proposals

Advanced search

Re: [std-proposals] throw = runtime_error;

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Sun, 13 Aug 2023 18:55:51 +0100
On Sun, 13 Aug 2023, 16:46 Jason McKesson via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> On Sun, Aug 13, 2023 at 10:24 AM Frederick Virchanza Gotham via
> Std-Proposals <std-proposals_at_[hidden]> wrote:
> >
> >
> > What if we could set the type of what's thrown within a try block, as
> follows:
> >
> > try
> > {
> > throw = std::runtime_error;
> >
> > if ( something ) throw "bad happened";
> >
> > if ( something ) throw "worse happened;
> >
> > throw = std::logic_error;
> >
> > if ( something ) throw "even worse happened";
> > }
> >
> > In the above snippet, the first two 'throw' statements throw an object
> of type 'runtime_error', and the third throws an object of type
> 'logic_error'.
> >
> > You could consider this feature to merely be a form of shorthand, but it
> could also be a versatile way of changing one line of code to affect much
> larger blocks of code.
>
> ... That's exactly what a form of "shorthand" is.
>
> There is no motivation for this change. Nothing you state explains why
> what you want would improve anything. You are just throwing out a
> thing that occurred to you.
>

As usual.

People could just stop replying to him.

Received on 2023-08-13 17:56:07