Ali Çehreli <[email protected]> wrote:

To further confuse the issue, assert throws too:

import std.stdio;
import std.algorithm;

void main()
{
     try {
         assert(false);
     } catch (Throwable) {
         writeln("an assertion failed");
     }
}

The difference is just the exception that is thrown. Throwable seems to be most general.

Seeing as how Error is supposed to be unrecoverable, and Exception might
be recoverable, and both inherit from Throwable, one should only very very
rarely catch Exception, and by extension, Throwable. One might in fact
argue that Error and Exception should have no common ancestor but Object.


From what I've read so far, I take enforce as a replacement to what it exactly is:

if (condition) {
     throw /* ... */;
}

That is indeed basically what it is.


--
Simen

Reply via email to