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
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost