fixed: extending std::runtime_error instead, as std::exception ctor is undefined. also fixed some mac warnings from inheriting runtime_error.

This commit is contained in:
Nick Bolton
2014-03-14 20:33:18 +00:00
parent ab529fae41
commit d5b25069be
18 changed files with 68 additions and 41 deletions

View File

@@ -27,29 +27,30 @@
//
XBase::XBase() :
m_what()
std::runtime_error("")
{
// do nothing
}
XBase::XBase(const CString& msg) :
m_what(msg)
std::runtime_error(msg)
{
// do nothing
}
XBase::~XBase()
XBase::~XBase() _NOEXCEPT
{
// do nothing
}
const char*
XBase::what() const
XBase::what() const _NOEXCEPT
{
if (m_what.empty()) {
m_what = getWhat();
const char* what = std::runtime_error::what();
if (strlen(what) == 0) {
return getWhat().c_str();
}
return m_what.c_str();
return what;
}
CString

View File

@@ -19,21 +19,22 @@
#pragma once
#include "base/String.h"
#include "common/stdexcept.h"
//! Exception base class
/*!
This is the base class of most exception types.
*/
class XBase : public std::exception {
class XBase : public std::runtime_error {
public:
//! Use getWhat() as the result of what()
XBase();
//! Use \c msg as the result of what()
XBase(const CString& msg);
virtual ~XBase();
virtual ~XBase() _NOEXCEPT;
//! Reason for exception
virtual const char* what() const;
virtual const char* what() const _NOEXCEPT;
protected:
//! Get a human readable string describing the exception
@@ -47,9 +48,6 @@ protected:
*/
virtual CString format(const char* id,
const char* defaultFormat, ...) const throw();
private:
mutable CString m_what;
};
/*!
@@ -63,6 +61,7 @@ class name_ : public super_ { \
public: \
name_() : super_() { } \
name_(const CString& msg) : super_(msg) { } \
virtual ~name_() _NOEXCEPT { } \
}
/*!
@@ -76,6 +75,7 @@ class name_ : public super_ { \
public: \
name_() : super_() { } \
name_(const CString& msg) : super_(msg) { } \
virtual ~name_() _NOEXCEPT { } \
\
protected: \
virtual CString getWhat() const throw(); \
@@ -97,8 +97,9 @@ private: \
public: \
name_() : super_(), m_state(kDone) { } \
name_(const CString& msg) : super_(msg), m_state(kFirst) { } \
virtual ~name_() _NOEXCEPT { } \
\
virtual const char* what() const \
virtual const char* what() const _NOEXCEPT \
{ \
if (m_state == kFirst) { \
m_state = kFormat; \