Files
filesystem/doc/exception.htm
2005-05-09 14:52:42 +00:00

178 lines
6.8 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Boost Filesystem exception.hpp Header</title>
</head>
<body bgcolor="#FFFFFF">
<h1>
<img border="0" src="../../../boost.png" align="center" width="277" height="86">Error
Reporting</h1>
<p><a href="#Introduction">Introduction</a><br>
<a href="#Synopsis">Synopsis</a><br>
<a href="#Members">Member functions</a><br>
<a href="#Non-members">Non-member functions</a><br>
&nbsp;&nbsp;&nbsp; <a href="#lookup_error_code">lookup_error_code</a><br>
&nbsp;&nbsp;&nbsp; <a href="#system_message">system_message</a><br>
<a href="#Acknowledgements">Acknowledgements</a></p>
<h2><a name="Introduction">Introduction</a></h2>
<p>The <a href="../../../boost/filesystem/path.hpp">boost/filesystem/path.hpp</a> header provides
various error reporting facilities, including class template <i>basic_filesystem_error</i>, publicly derived from <i>
std::runtime_error</i>. These facilities are used by functions in the Filesystem Library to
report operational errors.</p>
<p>The design evolved based on user requests to ease portability and
internationalization. See the Boost <a href="../../../more/error_handling.html">
Error and Exception Handling</a> guidelines.</p>
<h2><a name="Synopsis">Synopsis</a></h2>
<pre>namespace boost
{
namespace filesystem
{
enum <a name="error_code">error_code</a>
{
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
};
typedef <i>implementation-defined</i> system_error_type;
error_code <a href="#lookup_error_code">lookup_error_code</a>( system_error_type sys_err_code );
void <a href="#system_message">system_message</a>( system_error_type sys_err_code, std::string &amp; target );
template&lt;class Path&gt;
class basic_filesystem_error : public std::exception
{
public:
// compiler generates copy constructor and copy assignment
typedef Path path_type;
<a href="#Constructors">basic_filesystem_error</a>( const std::string &amp; what, system_error_type se );
<a href="#Constructors">basic_filesystem_error</a>( const std::string &amp; what, const path &amp; path1, system_error_type se );
<a href="#Constructors">basic_filesystem_error</a>( const std::string &amp; what, const path &amp; path1,
const path &amp; path2, system_error_type se );
~basic_filesystem_error() throw();
virtual const char * <a href="#what">what</a>() const throw();
system_error_type <a href="#system_error">system_error</a>() const;
const path &amp; <a href="#path1">path1</a>() const;
const path &amp; <a href="#path2">path2</a>() const;
};
typedef basic_filesystem_error&lt;path&gt; filesystem_error;
typedef basic_filesystem_error&lt;wpath&gt; wfilesystem_error;
} // namespace filesystem
} // namespace boost
</pre>
<p>For POSIX and Windows, <code>system_error_type</code> is <code>int</code>.</p>
<h2><a name="Members">Member functions</a></h2>
<h3><a name="Constructors">Constructors</a></h3>
<pre> <a href="#Constructors">basic_filesystem_error</a>( const std::string &amp; what, system_error_type se );
<a href="#Constructors">basic_filesystem_error</a>( const std::string &amp; what, const path &amp; path1, system_error_type se );
<a href="#Constructors">basic_filesystem_error</a>( const std::string &amp; what, const path &amp; path1,
const path &amp; path2, system_error_type se );</pre>
<blockquote>
<p><b>Effects:</b> Constructs a <i>basic_filesystem_error</i> object, initialized
from the appropriate arguments.</p>
</blockquote>
<h3><a name="what">what</a></h3>
<blockquote>
<p><code>virtual const char * what() const throw();</code></p>
<p><b>Returns:</b> A string identifying the error, including path1(),
path2(), and related messages. If an error occurs in the preparation of the
string, particularly in low-memory situations, an implementation is permitted to
return a simpler static string.</p>
</blockquote>
<h3><a name="system_error">system_error</a></h3>
<blockquote>
<p><code>system_error_type system_error() const;</code></p>
<p><b>Returns:</b> The <code>se</code> argument to the constructor.</p>
</blockquote>
<h3><a name="path1">path1</a></h3>
<blockquote>
<pre>const path &amp; path1() const;</pre>
<p><b>Returns:</b> The <code>path1</code> argument to the constructor, if any,
otherwise <code>path()</code>. An implementation is permitted to return an empty
path if an exception, for example, std::bad_alloc,&nbsp;occurs during
processing.</p>
</blockquote>
<h3><a name="path2">path2</a></h3>
<blockquote>
<pre>const path &amp; path2() const;</pre>
<p><b>Returns:</b> The <code>path2</code> argument to the constructor, if any,
otherwise <code>path()</code>. An implementation is permitted to return an empty
path if an exception, for example, std::bad_alloc,&nbsp;occurs during
processing.</p>
</blockquote>
<h2><a name="Non-members">Non-member functions</a></h2>
<h3><a name="lookup_error_code">lookup_error_code</a></h3>
<blockquote>
<pre>error_code lookup_error_code( system_error_type sys_err_code );</pre>
<p><b>Returns:</b> <code><a href="#error_code">error_code</a></code>
corresponding to <code>sys_err_code</code></p>
</blockquote>
<h3><a name="system_message">system_message</a></h3>
<blockquote>
<pre>void system_message( system_error_type sys_err_code, std::string &amp; target );</pre>
<p><b>Effects:</b> Appends an operating system message corresponding to
sys_err_code to <code>target</code>.</p>
</blockquote>
<h2><a name="Acknowledgements">Acknowledgements</a></h2>
<p>Peter Dimov patiently identified requirements for portability and
internationalization of error messages. </p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->09 May, 2005<!--webbot bot="Timestamp" endspan i-checksum="14004" --></p>
<p>© Copyright Beman Dawes, 2002</p>
<p> Use, modification, and distribution are subject to the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
www.boost.org/LICENSE_1_0.txt</a>)</p>
</body>
</html>