From: David Brownstein (David_at_[hidden])
Date: 2002-07-31 16:18:58
I was reading the following message, and it took me down a completely
different path... I'd like to propose a small utility class, if there is
I noticed that remove() is a function that returns void, AND throws
exceptions to report various error conditions. Generally this kind of usage
of exceptions (using exceptions as an alternative way of reporting an error
when a return value would suffice) really bothers me, because 1) there is
considerable overhead that is avoidable using normal return values, and 2)
if a programmer "forgets" to capture/check a return value, the reported
failure *might* not halt program execution, but failure to use a try/catch
Anyway, I realize that one of the reasons exceptions are used to report
error conditions is the ability to transmit additional information about the
error. The std::logic_error is a good example of this- the CTOR takes a
const string&, which allows the user to throw an excpetion and provide a
description of the error. The "consumer" can use the logic_error.what()
method to extract the reason.
SO- wouldn't it be nice if we could have an error return that supported
return codes (like true|false, or -1, etc.), and also allow the reporting of
a human readable description (a la std::logic_error)? To this end I have
written a simple class, with a (type templated) return value combined with a
description string. It is attached here, embedded in a simple test program.
Let me know if this is interesting...
----- Original Message -----
From: "Keith Burton" <kb_at_[hidden]>
Sent: Wednesday, July 31, 2002 11:01 AM
Subject: RE: [boost] Review Request: Filesystem Library
> Operations documentation
> void remove( const path & ph );
> Postcondition: !exists( ph )
> Throws: if !exists(ph) || !is_empty(ph)
> the throw specification needs amplification and correction :
> Throws : pre-condition : if ( ! exists( ph ) || ( is_directory( ph ) &&
> ! is_empty( ph ) ) )
> : post-condition : if ( exists( ph ) )
> Incidentally , I do not believe that remove should throw if ! exists( ph
> My rationale being the ones who care can use exists( ph ) before and
> those who do not get least surprise.
> Keith Burton
> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Beman Dawes
> Sent: 30 July 2002 20:28
> To: boost_at_[hidden]
> Subject: [boost] Review Request: Filesystem Library
> Please add the Filesystem Library to the queue for a Formal Review.
> The library can be downloaded from
> It is also available in the Boost sandbox CVS on SourceForge. See
> This release includes several improvements suggested by Thomas Witt and
> Baptiste Lepilleur.
> The current implementation has been tested under Windows 2000, and
> the regression tests for Borland, GCC 3.1, Intel 6.0, Metrowerks 8.1,
> Microsoft VC++ 7.0. Most of the library can be used with VC++ 6.0, but
> fstream.hpp header won't work due to a VC++ library bug. An earlier
> version passed the tests on Linux/GCC.
> The current implementation is supposed to work on any POSIX system, but
> that support hasn't been fully tested. Reports of tests on POSIX
> would be appreciated.
> Unsubscribe & other changes:
> Unsubscribe & other changes:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk