Fix missing error messages (part 2)

refs #7331
This commit is contained in:
Gunnar Beutner 2014-10-01 16:01:47 +01:00
parent a08f4588eb
commit 15358c6e95
10 changed files with 27 additions and 37 deletions

View File

@ -23,7 +23,7 @@ mkclass_target(streamlogger.ti streamlogger.thpp)
mkclass_target(sysloglogger.ti sysloglogger.thpp)
set(base_SOURCES
application.cpp application.thpp array.cpp context.cpp
application.cpp application.thpp array.cpp configerror.cpp context.cpp
convert.cpp debuginfo.cpp dictionary.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp
exception.cpp fifo.cpp filelogger.cpp filelogger.thpp logger.cpp logger.thpp
netstring.cpp networkstream.cpp object.cpp objectlock.cpp process.cpp

View File

@ -17,12 +17,19 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#include "config/configerror.hpp"
#include "base/configerror.hpp"
#include <sstream>
using namespace icinga;
ConfigError::ConfigError(const String& message)
: user_error(message)
: m_Message(message)
{ }
ConfigError::~ConfigError(void) throw()
{ }
const char *ConfigError::what(void) const throw()
{
return m_Message.CStr();
}

View File

@ -20,7 +20,7 @@
#ifndef CONFIGERROR_H
#define CONFIGERROR_H
#include "config/i2-config.hpp"
#include "base/i2-base.hpp"
#include "base/debuginfo.hpp"
#include "base/exception.hpp"
@ -28,12 +28,18 @@ namespace icinga
{
/*
* @ingroup config
* @ingroup base
*/
class I2_CONFIG_API ConfigError : virtual public user_error
class I2_BASE_API ConfigError : virtual public user_error
{
public:
ConfigError(const String& message);
~ConfigError(void) throw();
virtual const char *what(void) const throw();
private:
String m_Message;
};
}

View File

@ -22,6 +22,7 @@
#include "base/debug.hpp"
#include "base/objectlock.hpp"
#include "base/convert.hpp"
#include "base/configerror.hpp"
using namespace icinga;
@ -100,7 +101,7 @@ void DynamicType::RegisterObject(const DynamicObject::Ptr& object)
if (it->second == object)
return;
BOOST_THROW_EXCEPTION(user_error("An object with type '" + m_Name + "' and name '" + name + "' already exists (" +
BOOST_THROW_EXCEPTION(ConfigError("An object with type '" + m_Name + "' and name '" + name + "' already exists (" +
Convert::ToString(it->second->GetDebugInfo()) + "), new declaration: " + Convert::ToString(object->GetDebugInfo()))
<< errinfo_debuginfo(object->GetDebugInfo()));
}

View File

@ -153,18 +153,3 @@ String icinga::DiagnosticInformation(boost::exception_ptr eptr)
return boost::diagnostic_information(eptr);
}
user_error::user_error(void)
{ }
user_error::user_error(const String& message)
: m_Message(message)
{ }
user_error::~user_error(void) throw()
{ }
const char *user_error::what(void) const throw()
{
return m_Message.CStr();
}

View File

@ -38,17 +38,8 @@
namespace icinga
{
class I2_BASE_API user_error : virtual public std::exception, virtual public boost::exception {
public:
user_error(void);
user_error(const String& message);
~user_error(void) throw();
const char *what(void) const throw();
private:
String m_Message;
};
class I2_BASE_API user_error : virtual public std::exception, virtual public boost::exception
{ };
I2_BASE_API StackTrace *GetLastExceptionStack(void);
I2_BASE_API void SetLastExceptionStack(const StackTrace& trace);

View File

@ -32,7 +32,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
set(config_SOURCES
aexpression.cpp applyrule.cpp base-type.conf base-type.cpp
configcompilercontext.cpp configcompiler.cpp configerror.cpp configitembuilder.cpp
configcompilercontext.cpp configcompiler.cpp configitembuilder.cpp
configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS}
configtype.cpp objectrule.cpp typerule.cpp typerulelist.cpp
)

View File

@ -18,7 +18,6 @@
******************************************************************************/
#include "config/aexpression.hpp"
#include "config/configerror.hpp"
#include "config/configitem.hpp"
#include "config/configitembuilder.hpp"
#include "config/applyrule.hpp"
@ -31,6 +30,7 @@
#include "base/objectlock.hpp"
#include "base/object.hpp"
#include "base/logger_fwd.hpp"
#include "base/configerror.hpp"
#include <boost/foreach.hpp>
#include <boost/exception_ptr.hpp>
#include <boost/exception/errinfo_nested_exception.hpp>

View File

@ -25,7 +25,6 @@
#include "config/configtype.hpp"
#include "config/configcompiler.hpp"
#include "config/configcompilercontext.hpp"
#include "config/configerror.hpp"
#include "config/typerule.hpp"
#include "config/typerulelist.hpp"
#include "config/aexpression.hpp"
@ -38,6 +37,7 @@
#include "base/scriptvariable.hpp"
#include "base/exception.hpp"
#include "base/dynamictype.hpp"
#include "base/configerror.hpp"
#include <sstream>
#include <stack>
#include <boost/foreach.hpp>

View File

@ -22,7 +22,6 @@
#include "config/applyrule.hpp"
#include "config/objectrule.hpp"
#include "config/configtype.hpp"
#include "config/configerror.hpp"
#include "base/application.hpp"
#include "base/dynamictype.hpp"
#include "base/objectlock.hpp"
@ -33,6 +32,7 @@
#include "base/exception.hpp"
#include "base/stdiostream.hpp"
#include "base/netstring.hpp"
#include "base/configerror.hpp"
#include <sstream>
#include <fstream>
#include <boost/foreach.hpp>