forked from boostorg/system
Merge system and filesystem branches, bringing them in sync with N2415. Several filesystem bugs fixed, and current_path setter added.
[SVN r39173]
This commit is contained in:
1 parent
1656e087bb
commit
04e774f337
12 files changed
+1466
-551
No files matched your search
@@ -17,59 +17,52 @@ namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
enum message_action { append_message, no_message };
|
||||
|
||||
// class system_error --------------------------------------------------//
|
||||
|
||||
class system_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit system_error( error_code ec )
|
||||
: std::runtime_error(std::string()), m_error_code(ec),
|
||||
m_append_message(true) {}
|
||||
|
||||
system_error( error_code ec, const std::string & what_arg,
|
||||
message_action ma = append_message )
|
||||
: std::runtime_error(what_arg), m_error_code(ec),
|
||||
m_append_message(ma==append_message) {}
|
||||
|
||||
system_error( error_code::value_type ev, error_category ecat )
|
||||
: std::runtime_error(std::string()), m_error_code(ev,ecat),
|
||||
m_append_message(true) {}
|
||||
|
||||
system_error( error_code::value_type ev, error_category ecat,
|
||||
const std::string & what_arg, message_action ma = append_message )
|
||||
: std::runtime_error(what_arg), m_error_code(ev,ecat),
|
||||
m_append_message(ma==append_message) {}
|
||||
system_error( error_code ec )
|
||||
: std::runtime_error(""), m_error_code(ec) {}
|
||||
system_error( error_code ec, const std::string & what_arg )
|
||||
: std::runtime_error(what_arg), m_error_code(ec) {}
|
||||
system_error( int ev, const error_category & ecat,
|
||||
const std::string & what_arg )
|
||||
: std::runtime_error(what_arg), m_error_code(ev,ecat) {}
|
||||
system_error( int ev, const error_category & ecat )
|
||||
: std::runtime_error(""), m_error_code(ev,ecat) {}
|
||||
|
||||
virtual ~system_error() throw() {}
|
||||
|
||||
const error_code & code() const throw() { return m_error_code; }
|
||||
|
||||
const char * what() const throw()
|
||||
// see http://www.boost.org/more/error_handling.html for lazy build rationale
|
||||
{
|
||||
if ( !m_error_code || !m_append_message ) return runtime_error::what();
|
||||
if ( m_what.empty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_what = runtime_error::what();
|
||||
if ( !m_what.empty() ) m_what += ": ";
|
||||
m_what += m_error_code.message();
|
||||
}
|
||||
catch (...) { return runtime_error::what(); }
|
||||
}
|
||||
return m_what.c_str();
|
||||
}
|
||||
|
||||
const error_code & code() const throw() { return m_error_code; }
|
||||
const char * what() const throw();
|
||||
|
||||
private:
|
||||
error_code m_error_code;
|
||||
mutable std::string m_what;
|
||||
bool m_append_message;
|
||||
};
|
||||
|
||||
// implementation ------------------------------------------------------//
|
||||
|
||||
inline const char * system_error::what() const throw()
|
||||
// see http://www.boost.org/more/error_handling.html for lazy build rationale
|
||||
{
|
||||
if ( m_what.empty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
m_what = this->runtime_error::what();
|
||||
if ( m_error_code )
|
||||
{
|
||||
if ( !m_what.empty() ) m_what += ": ";
|
||||
m_what += m_error_code.message();
|
||||
}
|
||||
}
|
||||
catch (...) { return runtime_error::what(); }
|
||||
}
|
||||
return m_what.c_str();
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
|
||||
Reference in new issue
Block a user