|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-01-16 10:44:39
"William E. Kempf" <wekempf_at_[hidden]> writes:
> Peter Dimov said:
>> From: "William E. Kempf" <wekempf_at_[hidden]>
>>> Peter Dimov said:
>>> >
>>> > The fact that who() returns a function name is not important; it is
>>> not a "mini call stack". A function name is used as a token that
>>> identifies the point of failure. What failed? An attempt to open a
>>> file? An attempt to read the contents of a directory? An attempt to
>>> copy a file? To move a file? You need this information in order to
>>> compose a meaninful error message. "No such file or directory" by
>>> itself isn't very helpful to the user. What is the name of the
>>> file/directory that wasn't found? What did the program try to do
>>> with it?
>>>
>>> But the "who" is dependent on higher level information than what's
>>> available to the library.
>>
>> No, who() is not dependent on higher level information. It only depends
>> on the location of the throw statement where the exception was created.
>
> Take this statement out of context, and I'd agree. Put it back into
> context and the point is that the originating function name is not enough
> contextual information to be useful, and the information that would be
> useful is at a higher level than what's available to the library.
In general I agree with Bill. The more code gets refactored and
encapsulated, the less useful the name of the throwing function will
be. Take for example boost::throw_exception. I know that one doesn't
really count, because the exception is constructed at a higher level,
but I hope I've made my point.
>> Every active exception has one and only one associated throw statement.
>>
>> To supply who() information, you only need to change
>>
>> throw E(...);
>>
>> to
>>
>> throw E("identifier", ...);
>>
>> with a suitable predefined "identifier" scheme.
>>
>> The sequence of events that led to that throw statement being executed,
>> the execution path, or the call stack might be nice to have, but they
>> aren't necessarily easy to obtain, and they aren't the information that
>> who() is intended to provide.
>
> And I argue the information that who() is intended to provide is not useful.
I'm not sure that's true in the specific case of the filesystem lib.
-- David Abrahams dave_at_[hidden] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk