On Friday, 3 June 2022 at 23:40:50 UTC, Steven Schveighoffer wrote:
During the last beerconf, I wrote a short blog post about how `Error` and `Exception` are different, and why you should never continue after catching `Error`s.

Feedback welcome, I didn't announce here when I wrote it because it's kind of small/insignificant, but maybe it can help newcomers to the language: https://www.schveiguy.com/blog/2022/05/comparing-exceptions-and-errors-in-d/

-Steve

Here my feedback:

1. What if div is called with x = -2147483648 and y = -1? Isn't code which allows a divisor == 0 to propagate to the CPU an error? Must the code thus not throw an object instantiated from a subclass of `Error`?

What if I have that function div used in code which is called from say controller code of a CGI binary. Or likewise from a vibe.d-thread servicing a web request? How do I isolate that fault? Do I have to spawn a subprocess
   as Walter suggested in the case of memory corruption [1]?

   [This is of course all rhetorical!]

2. Since 2017 or so I have written some 10 KLOC of D, maybe about two dozen classes deriving from Exception. But I did not annotate any of my methods or function with "nothrow" nor did I author any class deriving from `Error`.

   What does that mean? Am I `Error` blind?

3. Can you provide some piece of code which *must* throw `Error` and cannot
   throw an appropriate Exception?

[1] http://forum.dlang.org/post/t6ef8c$1cu5$1...@digitalmars.com
    Re: Why is D unpopular?

Reply via email to