On 2015-05-13 17:08, Adam D. Ruppe wrote:
Have you ever done:

if(something) {
    import std.conv;
    throw new Exception("some error " ~ to!string(some_value));
}

Don't you hate it?

* having to import std.conv to see data from your exception is a pain
* it allocates eagerly and thus isn't suitable for a lot of places
* inspecting the data can be a pain as the string is unstructured

This assumes the data is even bothered to be added. Anyone who has
gotten a RangeError in D knows important information is often just dropped!

A good solution is to make a new exception subclass for each error type,
storing details as data members. However, that's a bit of a pain in D
because of all the work you have to do to make a complete subclass:

Yeah, I really hate that people are using plain Exception instead of creating a subclass. I'm trying to point this out in pull requests and similar but it's hard to get people to listen.

One thing that is _not_ making things better is "enforce" which, if I recall correctly, throws Exception by default.

I think this is related: http://wiki.dlang.org/DIP33

--
/Jacob Carlborg

Reply via email to