Introduction
Synopsis
Member functions
Acknowledgements
The header provides class filesystem_error, publicly derived from std::runtime_error, which is used by functions in the Filesystem Library to report operational errors.
The design evolved based on user requests to ease portability and internationalization.
namespace boost { namespace filesystem { enum error_code { no_error = 0, system_error, // system generated error; if possible, is translated // to one of the more specific errors below. other_error, // library generated error security_error, // includes access rights, permissions failures read_only_error, io_error, path_error, not_found_error, not_directory_error, busy_error, // implies trying again might succeed already_exists_error, not_empty_error, is_directory_error, out_of_space_error, out_of_memory_error, out_of_resource_error }; class filesystem_error : public std::runtime_error { public: filesystem_error( const std::string & who, const std::string & message ); filesystem_error( const std::string & who, const path & path1, const std::string & message ); filesystem_error( const std::string & who, const path & path1, sys_err sys_err_code ); filesystem_error( const std::string & who, const path & path1, const path & path2, sys_err sys_err_code ); ~filesystem_error() throw(); sys_err native_error() const; error_code error() const; const std::string & who() const; const path & path1() const; const path & path2() const; }; } // namespace filesystem } // namespace boost
For POSIX and Windows, sys_err
is int
. For
other operating systems, it is implementation defined.
filesystem_error( const std::string & who, const std::string & message ); filesystem_error( const std::string & who, const path & path1, const std::string & message ); filesystem_error( const std::string & who, const path & path1, int sys_err_code ); filesystem_error( const std::string & who, const path & path1, const path & path2, int sys_err_code );Precondition: The
who
argument is in the form, as appropriate:
- boost::filesystem::class-name::function-name for errors from public member functions
- boost::filesystem::class-name for errors not identified with a particular member function.
- boost::filesystem::function-name for errors from non-member functions.
These forms are explicitly specified to ensure portability of user programs between library implementations.
Effects: Constructs a filesystem_error object.
sys_err
native_error() const;
Returns: The
sys_err_code
argument to the constructor, if any. Otherwise, 0.
error_code error() const;Returns:
native_error()
translated toerror_code
. The translation is implementation-defined. For the POSIX and Windows implementations, see libs/filesystem/src/exception.cpp.
const std::string & who() const;Returns: The
who
argument to the constructor.
const path & path1() const;Returns: The
path1
argument to the constructor, if any, otherwisepath()
.
const path & path2() const;Returns: The
path2
argument to the constructor, if any, otherwisepath()
.
Peter Dimov patently identified requirements for portability and internationalization of error messages.
© Copyright Beman Dawes, 2002
Revised 02 January, 2003