newbie problem with nothrow

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 31 15:29:19 PDT 2016


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.");

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list