newbie problem with nothrow

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 1 07:57:38 PDT 2016


On 10/31/16 6:29 PM, Jonathan M Davis via Digitalmars-d-learn wrote:
> On Monday, October 31, 2016 22:20:59 Kapps via Digitalmars-d-learn wrote:
>> Assuming you're sure it'll never throw. To enforce this, use try
>> { } catch { throw new Error("blah"); }. You can still throw
>> errors, just not exceptions (as errors are not meant to be
>> caught).
>
> I always use assert(0). e.g.
>
> try
>     return format("%s", 42);
> catch(Exception)
>     assert(0, "format threw when it shouldn't be possible.");

This turns into a non-printing seg fault when compiled in release mode.

Is there not some assumeNoThrow wrapper somewhere?

-Steve


More information about the Digitalmars-d-learn mailing list