Comparing Exceptions and Errors
kdevel
kdevel at vogtner.de
Sun Jun 5 11:43:32 UTC 2022
On Sunday, 5 June 2022 at 00:40:26 UTC, Ali Çehreli wrote:
[...]
> Errors are thrown when the program is discovered to be in an
> invalid state.
The following program throws an `Error` in popFront:
import std.range;
void main ()
{
int [1] a;
auto q = a[1..$]; // line 6
q.popFront; // line 7, throws
core.exception.AssertError
}
When the program counter (PC) is at line 6 the program is in a
valid state.
At no time the program is in an invalid state and it would not
pass into an invalid state if popFront threw an `Exception`
instead of an `Error`.
More information about the Digitalmars-d-learn
mailing list