Files
filesystem/doc/exception.htm
Beman Dawes 48d4335bfc merge from i18n branch - at last!
[SVN r32079]
2005-12-16 16:40:35 +00:00

163 lines
6.7 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::exception</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
{
typedef int <a name="errno_type">errno_type</a>; // determined by C standard; POSIX defers to C standard
typedef <i>implementation-defined</i> <a name="system_error_type">system_error_type</a>;
errno_type <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><a href="#system_error_type">system_error_type</a> 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><a href="#errno_type">errno_type</a> lookup_error_code( <a href="#system_error_type">system_error_type</a> sys_err_code );</pre>
<p><b>Returns:</b> A value
corresponding to <code>sys_err_code.</code> Macros for errno_type values are
defined in <a href="../../../boost/filesystem/cerrno.hpp">&lt;boost/filesystem/cerrno.hpp&gt;</a>,
and are described in [<a href="design.htm#POSIX-01">POSIX-01</a>] under
<a href="http://www.opengroup.org/onlinepubs/009695399/basedefs/errno.h.html">
&lt;errno.h&gt;</a>..</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. He also suggested basing the portable
error codes on POSIX.</p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->21 June, 2005<!--webbot bot="Timestamp" endspan i-checksum="19912" --></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>