More exception classes into Phobos?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 28 02:25:33 PDT 2017


On 3/25/2017 6:44 AM, Jacob Carlborg wrote:
> Talk about just providing a generic exception type. Take this error message,
> using std.file.copy:
>
> std.file.FileException at d.d(3354): /tmp/bar/foo.txt: Permission denied
>
> It doesn't tell if the failed permission is for the source or for the target. If
> failed to read or failed to write.


If you received an IOException instead, you're no better off. As Andrei 
observed, it is the message that's the problem, not the exception type.

In general, I think a lot of the issues you brought up are inadequate messages, 
or trying to solve the problem at the wrong level of the function call hierarchy 
(i.e. too far up).

In any case, trying to get good messages to the user is a never ending problem. 
No solution will be universal. It's actually a lot like writing portable code. 
People who have never ported code tend to make all the wrong choices in where to 
make things portable (see windows.h for 16 bit Windows). Crafting an exception 
hierarchy with no experience with nor clear idea of the problem one is trying to 
solve just creates a complex, useless mess. I fear that's the path we've gone down.

P.S. I've worked with trying to internationalize error messages. What a mess! 
The foreign language string tables tend to be written by people who knew the 
foreign language, but had little idea of the product domain. So the messages 
tended to be so bad/outdated/garbled that people would just prefer the English ones.



More information about the Digitalmars-d mailing list