$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Beman Dawes (bdawes_at_[hidden])
Date: 2003-08-05 10:18:29
At 05:23 PM 8/1/2003, David Abrahams wrote:
 >
 >Why aren't there constructors accepting an error_code in
 >boost::fs::exception?
 >
 >I have some code which needs to throw an exception if
 >!is_directory(some_path).  I'd like to throw a not_a_directory
 >filesystem exception (or one derived therefrom).
 >
 >Howto?
Seems like there should be additional constructors:
       filesystem_error(
         const std::string & who,
         const path & path1,
         error_code err_code );
       filesystem_error(
         const std::string & who,
         const path & path1,
         const path & path2,
         error_code err_code );
There are several issues:
* Instead of mapping a system error code into a generic error code, the 
reverse will need to be done. This allows the error message mechanism to 
work as if the system had reported the error.
* Having constructors which are distinguished only by one argument being of 
type error_code or type int (for system specific error codes) may confuse 
users. I don't see any way around that.
* If I was starting from scratch, I'd probably fold four constructors into 
two by redoing the arguments for both the generic error code and system 
specific error code like this:
       filesystem_error(
         int err_code,
         const std::string & who,
         const path & path1,
         const path & path2 = "" );
Hum... The current argument ordering wouldn't be broken by adding the new 
ordering. That would allow a period of transition without breaking any 
existing code.
Comments?
--Beman