mkclass_target(sysloglogger.ti sysloglogger.thpp)
set(base_SOURCES
- application.cpp application-version.cpp application.thpp array.cpp configerror.cpp console.cpp context.cpp
+ application.cpp application-version.cpp application.thpp array.cpp console.cpp context.cpp
convert.cpp debuginfo.cpp dictionary.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp
exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp logger.cpp logger.thpp
netstring.cpp networkstream.cpp object.cpp primitivetype.cpp process.cpp
- ringbuffer.cpp scriptfunction.cpp scriptfunctionwrapper.cpp scriptsignal.cpp
+ ringbuffer.cpp scripterror.cpp scriptfunction.cpp scriptfunctionwrapper.cpp scriptsignal.cpp
scriptutils.cpp scriptvariable.cpp serializer.cpp socket.cpp stacktrace.cpp
statsfunction.cpp stdiostream.cpp stream.cpp streamlogger.cpp streamlogger.thpp string.cpp
sysloglogger.cpp sysloglogger.thpp tcpsocket.cpp thinmutex.cpp threadpool.cpp timer.cpp
}
}
-std::string icinga::to_string(const errinfo_debuginfo& e)
-{
- std::ostringstream msgbuf;
- msgbuf << "Config location: " << e.value() << "\n";
- ShowCodeFragment(msgbuf, e.value(), true);
- return msgbuf.str();
-}
-
I2_BASE_API void ShowCodeFragment(std::ostream& out, const DebugInfo& di, bool verbose);
-struct errinfo_debuginfo_;
-typedef boost::error_info<struct errinfo_debuginfo_, DebugInfo> errinfo_debuginfo;
-
-I2_BASE_API std::string to_string(const errinfo_debuginfo& e);
-
}
#endif /* DEBUGINFO_H */
#include "base/debug.hpp"
#include "base/objectlock.hpp"
#include "base/convert.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
using namespace icinga;
if (it->second == object)
return;
- 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()));
+ BOOST_THROW_EXCEPTION(ScriptError("An object with type '" + m_Name + "' and name '" + name + "' already exists (" +
+ Convert::ToString(it->second->GetDebugInfo()) + "), new declaration: " + Convert::ToString(object->GetDebugInfo()),
+ object->GetDebugInfo()));
}
m_ObjectMap[name] = object;
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include <sstream>
using namespace icinga;
-ConfigError::ConfigError(const String& message)
+ScriptError::ScriptError(const String& message)
: m_Message(message)
{ }
-ConfigError::~ConfigError(void) throw()
+ScriptError::ScriptError(const String& message, const DebugInfo& di)
+ : m_Message(message), m_DebugInfo(di)
{ }
-const char *ConfigError::what(void) const throw()
+ScriptError::~ScriptError(void) throw()
+{ }
+
+const char *ScriptError::what(void) const throw()
{
return m_Message.CStr();
}
+
+DebugInfo ScriptError::GetDebugInfo(void) const
+{
+ return m_DebugInfo;
+}
+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
-#ifndef CONFIGERROR_H
-#define CONFIGERROR_H
+#ifndef SCRIPTERROR_H
+#define SCRIPTERROR_H
#include "base/i2-base.hpp"
#include "base/debuginfo.hpp"
/*
* @ingroup base
*/
-class I2_BASE_API ConfigError : virtual public user_error
+class I2_BASE_API ScriptError : virtual public user_error
{
public:
- ConfigError(const String& message);
- ~ConfigError(void) throw();
+ ScriptError(const String& message);
+ ScriptError(const String& message, const DebugInfo& di);
+ ~ScriptError(void) throw();
virtual const char *what(void) const throw();
+ DebugInfo GetDebugInfo(void) const;
+
private:
String m_Message;
+ DebugInfo m_DebugInfo;
};
}
-#endif /* CONFIGERROR_H */
+#endif /* SCRIPTERROR_H */
#include "base/objectlock.hpp"
#include "base/dynamictype.hpp"
#include "base/application.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <algorithm>
void ScriptUtils::Assert(const Value& arg)
{
if (!arg.ToBool())
- BOOST_THROW_EXCEPTION(ConfigError("Assertion failed"));
+ BOOST_THROW_EXCEPTION(std::runtime_error("Assertion failed"));
}
try {
VMFrame frame;
expression->Evaluate(frame);
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
- ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
+ } catch (const ScriptError& ex) {
+ ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());
} catch (const std::exception& ex) {
ConfigCompilerContext::GetInstance()->AddMessage(true, DiagnosticInformation(ex));
}
std::cout << result;
std::cout << ConsoleColorTag(Console_Normal) << "\n";
}
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
+ } catch (const ScriptError& ex) {
+ DebugInfo di = ex.GetDebugInfo();
- if (di) {
- std::cout << String(3 + di->FirstColumn, ' ');
- std::cout << String(di->LastColumn - di->FirstColumn + 1, '^');
- std::cout << "\n";
- }
+ std::cout << String(3 + di.FirstColumn, ' ');
+ std::cout << String(di.LastColumn - di.FirstColumn + 1, '^');
+ std::cout << "\n";
std::cout << ex.what() << "\n";
} catch (const std::exception& ex) {
}
<STRING>\n {
- BOOST_THROW_EXCEPTION(ConfigError("Unterminated string literal") << errinfo_debuginfo(*yylloc));
+ BOOST_THROW_EXCEPTION(ScriptError("Unterminated string literal", *yylloc));
}
<STRING>\\[0-7]{1,3} {
if (result > 0xff) {
/* error, constant is out-of-bounds */
- BOOST_THROW_EXCEPTION(ConfigError("Constant is out of bounds: " + String(yytext)) << errinfo_debuginfo(*yylloc));
+ BOOST_THROW_EXCEPTION(ScriptError("Constant is out of bounds: " + String(yytext), *yylloc));
}
yyextra->m_LexBuffer << static_cast<char>(result);
/* generate error - bad escape sequence; something
* like '\48' or '\0777777'
*/
- BOOST_THROW_EXCEPTION(ConfigError("Bad escape sequence found: " + String(yytext)) << errinfo_debuginfo(*yylloc));
+ BOOST_THROW_EXCEPTION(ScriptError("Bad escape sequence found: " + String(yytext), *yylloc));
}
<STRING>\\n { yyextra->m_LexBuffer << "\n"; }
yyextra->m_LexBuffer << *yptr++;
}
-<STRING><<EOF>> { BOOST_THROW_EXCEPTION(ConfigError("End-of-file while in string literal") << errinfo_debuginfo(*yylloc)); }
+<STRING><<EOF>> { BOOST_THROW_EXCEPTION(ScriptError("End-of-file while in string literal", *yylloc)); }
\{\{\{ { yyextra->m_LexBuffer.str(""); yyextra->m_LexBuffer.clear(); BEGIN(HEREDOC); }
}
<C_COMMENT><<EOF>> {
- BOOST_THROW_EXCEPTION(ConfigError("End-of-file while in comment") << errinfo_debuginfo(*yylloc));
+ BOOST_THROW_EXCEPTION(ScriptError("End-of-file while in comment", *yylloc));
}
#include "base/scriptvariable.hpp"
#include "base/exception.hpp"
#include "base/dynamictype.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include <sstream>
#include <stack>
#include <boost/foreach.hpp>
void yyerror(YYLTYPE *locp, std::vector<Expression *> *, ConfigCompiler *, const char *err)
{
- BOOST_THROW_EXCEPTION(ConfigError(err) << errinfo_debuginfo(*locp));
+ BOOST_THROW_EXCEPTION(ScriptError(err, *locp));
}
int yyparse(std::vector<Expression *> *elist, ConfigCompiler *context);
if (seen_assign) {
if (!ObjectRule::IsValidSourceType(type))
- BOOST_THROW_EXCEPTION(ConfigError("object rule 'assign' cannot be used for type '" + type + "'") << errinfo_debuginfo(DebugInfoRange(@2, @3)));
+ BOOST_THROW_EXCEPTION(ScriptError("object rule 'assign' cannot be used for type '" + type + "'", DebugInfoRange(@2, @3)));
if (ignore) {
Expression *rex = new LogicalNegateExpression(ignore, DebugInfoRange(@2, @5));
| T_ASSIGN T_WHERE rterm
{
if ((context->m_Apply.empty() || !context->m_Apply.top()) && (context->m_ObjectAssign.empty() || !context->m_ObjectAssign.top()))
- BOOST_THROW_EXCEPTION(ConfigError("'assign' keyword not valid in this context."));
+ BOOST_THROW_EXCEPTION(ScriptError("'assign' keyword not valid in this context.", DebugInfoRange(@1, @3)));
context->m_SeenAssign.top() = true;
| T_IGNORE T_WHERE rterm
{
if ((context->m_Apply.empty() || !context->m_Apply.top()) && (context->m_ObjectAssign.empty() || !context->m_ObjectAssign.top()))
- BOOST_THROW_EXCEPTION(ConfigError("'ignore' keyword not valid in this context."));
+ BOOST_THROW_EXCEPTION(ScriptError("'ignore' keyword not valid in this context.", DebugInfoRange(@1, @3)));
if (context->m_Ignore.top())
context->m_Ignore.top() = new LogicalOrExpression(context->m_Ignore.top(), $3, DebugInfoRange(@1, @3));
free($6);
if (!ApplyRule::IsValidSourceType(type))
- BOOST_THROW_EXCEPTION(ConfigError("'apply' cannot be used with type '" + type + "'") << errinfo_debuginfo(DebugInfoRange(@2, @3)));
+ BOOST_THROW_EXCEPTION(ScriptError("'apply' cannot be used with type '" + type + "'", DebugInfoRange(@2, @3)));
if (!ApplyRule::IsValidTargetType(type, target)) {
if (target == "") {
typeNames += "'" + types[i] + "'";
}
- BOOST_THROW_EXCEPTION(ConfigError("'apply' target type is ambiguous (can be one of " + typeNames + "): use 'to' to specify a type") << errinfo_debuginfo(DebugInfoRange(@2, @3)));
+ BOOST_THROW_EXCEPTION(ScriptError("'apply' target type is ambiguous (can be one of " + typeNames + "): use 'to' to specify a type", DebugInfoRange(@2, @3)));
} else
- BOOST_THROW_EXCEPTION(ConfigError("'apply' target type '" + target + "' is invalid") << errinfo_debuginfo(DebugInfoRange(@2, @5)));
+ BOOST_THROW_EXCEPTION(ScriptError("'apply' target type '" + target + "' is invalid", DebugInfoRange(@2, @5)));
}
DictExpression *exprl = dynamic_cast<DictExpression *>($8);
// assign && !ignore
if (!context->m_SeenAssign.top())
- BOOST_THROW_EXCEPTION(ConfigError("'apply' is missing 'assign'") << errinfo_debuginfo(DebugInfoRange(@2, @3)));
+ BOOST_THROW_EXCEPTION(ScriptError("'apply' is missing 'assign'", DebugInfoRange(@2, @3)));
context->m_SeenAssign.pop();
#include "base/netstring.hpp"
#include "base/serializer.hpp"
#include "base/json.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include <sstream>
#include <fstream>
#include <boost/foreach.hpp>
VMFrame frame(dobj);
frame.Locals = m_Scope;
m_Expression->Evaluate(frame, &debugHints);
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
- ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
+ } catch (const ScriptError& ex) {
+ ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());
} catch (const std::exception& ex) {
ConfigCompilerContext::GetInstance()->AddMessage(true, DiagnosticInformation(ex));
}
try {
ctype->ValidateItem(GetName(), dobj, GetDebugInfo(), &utils);
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
- ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
+ } catch (const ScriptError& ex) {
+ ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());
} catch (const std::exception& ex) {
ConfigCompilerContext::GetInstance()->AddMessage(true, DiagnosticInformation(ex));
}
#include "base/json.hpp"
#include "base/object.hpp"
#include "base/logger.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include <boost/foreach.hpp>
#include <boost/exception_ptr.hpp>
#include <boost/exception/errinfo_nested_exception.hpp>
return DoEvaluate(frame, dhint);
} catch (const InterruptExecutionError&) {
throw;
+ } catch (const ScriptError& ex) {
+ throw;
} catch (const std::exception& ex) {
- if (boost::get_error_info<boost::errinfo_nested_exception>(ex))
- throw;
- else
- BOOST_THROW_EXCEPTION(ConfigError("Error while evaluating expression: " + String(ex.what()))
- << boost::errinfo_nested_exception(boost::current_exception())
- << errinfo_debuginfo(GetDebugInfo()));
+ BOOST_THROW_EXCEPTION(ScriptError("Error while evaluating expression: " + String(ex.what()), GetDebugInfo())
+ << boost::errinfo_nested_exception(boost::current_exception()));
}
}
if (right.IsEmpty())
return false;
else if (!right.IsObjectType<Array>())
- BOOST_THROW_EXCEPTION(ConfigError("Invalid right side argument for 'in' operator: " + JsonEncode(right)));
+ BOOST_THROW_EXCEPTION(ScriptError("Invalid right side argument for 'in' operator: " + JsonEncode(right), GetDebugInfo()));
Value left = m_Operand1->Evaluate(frame);
if (right.IsEmpty())
return true;
else if (!right.IsObjectType<Array>())
- BOOST_THROW_EXCEPTION(ConfigError("Invalid right side argument for 'in' operator: " + JsonEncode(right)));
+ BOOST_THROW_EXCEPTION(ScriptError("Invalid right side argument for 'in' operator: " + JsonEncode(right), GetDebugInfo()));
Value left = m_Operand1->Evaluate(frame);
object = indexExpr->Evaluate(frame, dhint);
if (!object)
- BOOST_THROW_EXCEPTION(ConfigError("Left-hand side argument must not be null."));
+ BOOST_THROW_EXCEPTION(ScriptError("Left-hand side argument must not be null.", GetDebugInfo()));
continue;
}
ConfigItem::Ptr item = ConfigItem::GetObject(type, name);
if (!item)
- BOOST_THROW_EXCEPTION(ConfigError("Import references unknown template: '" + name + "'"));
+ BOOST_THROW_EXCEPTION(ScriptError("Import references unknown template: '" + name + "'", GetDebugInfo()));
item->GetExpression()->Evaluate(frame, dhint);
#include "base/array.hpp"
#include "base/dictionary.hpp"
#include "base/scriptfunction.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include "base/convert.hpp"
#include <boost/foreach.hpp>
#include <boost/thread/future.hpp>
#include "base/scriptfunction.hpp"
#include "base/scriptsignal.hpp"
#include "base/scriptvariable.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include "base/convert.hpp"
#include "base/objectlock.hpp"
#include <boost/foreach.hpp>
func = ScriptFunction::GetByName(funcName);
if (!func)
- BOOST_THROW_EXCEPTION(ConfigError("Function '" + funcName + "' does not exist."));
+ BOOST_THROW_EXCEPTION(ScriptError("Function '" + funcName + "' does not exist."));
return func->Invoke(arguments);
}
ScriptSignal::Ptr sig = ScriptSignal::GetByName(signal);
if (!sig)
- BOOST_THROW_EXCEPTION(ConfigError("Signal '" + signal + "' does not exist."));
+ BOOST_THROW_EXCEPTION(ScriptError("Signal '" + signal + "' does not exist."));
sig->AddSlot(boost::bind(SlotWrapper, slot, _1));
if (oldItem) {
std::ostringstream msgbuf;
msgbuf << "Object '" << name << "' of type '" << type << "' re-defined: " << debugInfo << "; previous definition: " << oldItem->GetDebugInfo();
- BOOST_THROW_EXCEPTION(ConfigError(msgbuf.str()) << errinfo_debuginfo(debugInfo));
+ BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), debugInfo));
}
}
if (name.FindFirstOf("!") != String::NPos) {
std::ostringstream msgbuf;
msgbuf << "Name for object '" << name << "' of type '" << type << "' is invalid: Object names may not contain '!'";
- BOOST_THROW_EXCEPTION(ConfigError(msgbuf.str()) << errinfo_debuginfo(debugInfo));
+ BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), debugInfo));
}
item->SetName(name);
{
if (value.IsObjectType<Array>()) {
if (!fvvar.IsEmpty())
- BOOST_THROW_EXCEPTION(ConfigError("Cannot use dictionary iterator for array.") << errinfo_debuginfo(debugInfo));
+ BOOST_THROW_EXCEPTION(ScriptError("Cannot use dictionary iterator for array.", debugInfo));
Array::Ptr arr = value;
}
} else if (value.IsObjectType<Dictionary>()) {
if (fvvar.IsEmpty())
- BOOST_THROW_EXCEPTION(ConfigError("Cannot use array iterator for dictionary.") << errinfo_debuginfo(debugInfo));
+ BOOST_THROW_EXCEPTION(ScriptError("Cannot use array iterator for dictionary.", debugInfo));
Dictionary::Ptr dict = value;
}
}
else
- BOOST_THROW_EXCEPTION(ConfigError("Invalid type in __for expression: " + value.GetTypeName()) << errinfo_debuginfo(debugInfo));
+ BOOST_THROW_EXCEPTION(ScriptError("Invalid type in __for expression: " + value.GetTypeName(), debugInfo));
return Empty;
}
return context->GetField(fid);
}
- static inline void SetField(const Object::Ptr& context, const String& field, const Value& value)
+ static inline void SetField(const Object::Ptr& context, const String& field, const Value& value, const DebugInfo& debugInfo = DebugInfo())
{
Dictionary::Ptr dict = dynamic_pointer_cast<Dictionary>(context);
Type::Ptr type = context->GetReflectionType();
if (!type)
- BOOST_THROW_EXCEPTION(ConfigError("Cannot set field on object."));
+ BOOST_THROW_EXCEPTION(ScriptError("Cannot set field on object.", debugInfo));
int fid = type->GetFieldId(field);
if (fid == -1)
- BOOST_THROW_EXCEPTION(ConfigError("Attribute '" + field + "' does not exist."));
+ BOOST_THROW_EXCEPTION(ScriptError("Attribute '" + field + "' does not exist.", debugInfo));
try {
context->SetField(fid, value);
} catch (const boost::bad_lexical_cast&) {
- BOOST_THROW_EXCEPTION(ConfigError("Attribute '" + field + "' cannot be set to value of type '" + value.GetTypeName() + "'"));
+ BOOST_THROW_EXCEPTION(ScriptError("Attribute '" + field + "' cannot be set to value of type '" + value.GetTypeName() + "'", debugInfo));
} catch (const std::bad_cast&) {
- BOOST_THROW_EXCEPTION(ConfigError("Attribute '" + field + "' cannot be set to value of type '" + value.GetTypeName() + "'"));
+ BOOST_THROW_EXCEPTION(ScriptError("Attribute '" + field + "' cannot be set to value of type '" + value.GetTypeName() + "'", debugInfo));
}
}
const std::vector<String>& funcargs, const Dictionary::Ptr& closedVars, const boost::shared_ptr<Expression>& expr)
{
if (arguments.size() < funcargs.size())
- BOOST_THROW_EXCEPTION(ConfigError("Too few arguments for function"));
+ BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function"));
VMFrame frame;
func = ScriptFunction::GetByName(funcName);
if (!func)
- BOOST_THROW_EXCEPTION(ConfigError("Function '" + funcName + "' does not exist."));
+ BOOST_THROW_EXCEPTION(ScriptError("Function '" + funcName + "' does not exist."));
func->Invoke(arguments);
}
#include "base/logger.hpp"
#include "base/context.hpp"
#include "base/workqueue.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include <boost/foreach.hpp>
using namespace icinga;
if (vinstances.IsObjectType<Array>()) {
if (!rule.GetFVVar().IsEmpty())
- BOOST_THROW_EXCEPTION(ConfigError("Array iterator requires value to be an array.") << errinfo_debuginfo(di));
+ BOOST_THROW_EXCEPTION(ScriptError("Array iterator requires value to be an array.", di));
Array::Ptr arr = vinstances;
}
} else if (vinstances.IsObjectType<Dictionary>()) {
if (rule.GetFVVar().IsEmpty())
- BOOST_THROW_EXCEPTION(ConfigError("Dictionary iterator requires value to be a dictionary.") << errinfo_debuginfo(di));
+ BOOST_THROW_EXCEPTION(ScriptError("Dictionary iterator requires value to be a dictionary.", di));
Dictionary::Ptr dict = vinstances;
try {
if (EvaluateApplyRule(host, rule))
rule.AddMatch();
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
- ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
+ } catch (const ScriptError& ex) {
+ ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());
}
}
}
try {
if (EvaluateApplyRule(service, rule))
rule.AddMatch();
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
- ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
+ } catch (const ScriptError& ex) {
+ ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());
}
}
}
#include "icinga/pluginutility.hpp"
#include "icinga/scheduleddowntime.hpp"
#include "config/configcompilercontext.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include "base/objectlock.hpp"
#include "base/convert.hpp"
#include "base/utility.hpp"
#include "base/logger.hpp"
#include "base/context.hpp"
#include "base/workqueue.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include <boost/foreach.hpp>
using namespace icinga;
if (vinstances.IsObjectType<Array>()) {
if (!rule.GetFVVar().IsEmpty())
- BOOST_THROW_EXCEPTION(ConfigError("Array iterator requires value to be an array.") << errinfo_debuginfo(di));
+ BOOST_THROW_EXCEPTION(ScriptError("Array iterator requires value to be an array.", di));
Array::Ptr arr = vinstances;
}
} else if (vinstances.IsObjectType<Dictionary>()) {
if (rule.GetFVVar().IsEmpty())
- BOOST_THROW_EXCEPTION(ConfigError("Dictionary iterator requires value to be a dictionary.") << errinfo_debuginfo(di));
+ BOOST_THROW_EXCEPTION(ScriptError("Dictionary iterator requires value to be a dictionary.", di));
Dictionary::Ptr dict = vinstances;
try {
if (EvaluateApplyRule(host, rule))
rule.AddMatch();
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
- ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
+ } catch (const ScriptError& ex) {
+ ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());
}
}
}
try {
if (EvaluateApplyRule(service, rule))
rule.AddMatch();
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
- ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
+ } catch (const ScriptError& ex) {
+ ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());
}
}
}
#include "base/dynamictype.hpp"
#include "base/logger.hpp"
#include "base/context.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include <boost/foreach.hpp>
using namespace icinga;
if (vinstances.IsObjectType<Array>()) {
if (!rule.GetFVVar().IsEmpty())
- BOOST_THROW_EXCEPTION(ConfigError("Array iterator requires value to be an array.") << errinfo_debuginfo(di));
+ BOOST_THROW_EXCEPTION(ScriptError("Array iterator requires value to be an array.", di));
Array::Ptr arr = vinstances;
}
} else if (vinstances.IsObjectType<Dictionary>()) {
if (rule.GetFVVar().IsEmpty())
- BOOST_THROW_EXCEPTION(ConfigError("Dictionary iterator requires value to be a dictionary.") << errinfo_debuginfo(di));
+ BOOST_THROW_EXCEPTION(ScriptError("Dictionary iterator requires value to be a dictionary.", di));
Dictionary::Ptr dict = vinstances;
try {
if (EvaluateApplyRule(host, rule))
rule.AddMatch();
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
- ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
+ } catch (const ScriptError& ex) {
+ ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());
}
}
}
try {
if (EvaluateApplyRule(service, rule))
rule.AddMatch();
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
- ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
+ } catch (const ScriptError& ex) {
+ ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());
}
}
}
#include "base/logger.hpp"
#include "base/context.hpp"
#include "base/workqueue.hpp"
-#include "base/configerror.hpp"
+#include "base/scripterror.hpp"
#include <boost/foreach.hpp>
using namespace icinga;
if (vinstances.IsObjectType<Array>()) {
if (!rule.GetFVVar().IsEmpty())
- BOOST_THROW_EXCEPTION(ConfigError("Array iterator requires value to be an array.") << errinfo_debuginfo(di));
+ BOOST_THROW_EXCEPTION(ScriptError("Array iterator requires value to be an array.", di));
Array::Ptr arr = vinstances;
}
} else if (vinstances.IsObjectType<Dictionary>()) {
if (rule.GetFVVar().IsEmpty())
- BOOST_THROW_EXCEPTION(ConfigError("Dictionary iterator requires value to be a dictionary.") << errinfo_debuginfo(di));
+ BOOST_THROW_EXCEPTION(ScriptError("Dictionary iterator requires value to be a dictionary.", di));
Dictionary::Ptr dict = vinstances;
try {
if (EvaluateApplyRule(host, rule))
rule.AddMatch();
- } catch (const ConfigError& ex) {
- const DebugInfo *di = boost::get_error_info<errinfo_debuginfo>(ex);
- ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), di ? *di : DebugInfo());
+ } catch (const ScriptError& ex) {
+ ConfigCompilerContext::GetInstance()->AddMessage(true, ex.what(), ex.GetDebugInfo());
}
}
}
delete expr;
expr = ConfigCompiler::CompileText("<test>", "\"foo\" in \"bar\"");
- BOOST_CHECK_THROW(expr->Evaluate(frame), ConfigError);
+ BOOST_CHECK_THROW(expr->Evaluate(frame), ScriptError);
delete expr;
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in [ \"bar\", \"baz\" ]");
delete expr;
expr = ConfigCompiler::CompileText("<test>", "\"foo\" !in \"bar\"");
- BOOST_CHECK_THROW(expr->Evaluate(frame), ConfigError);
+ BOOST_CHECK_THROW(expr->Evaluate(frame), ScriptError);
delete expr;
expr = ConfigCompiler::CompileText("<test>", "{ a += 3 }");
BOOST_CHECK(dict->Get("a") == 3);
expr = ConfigCompiler::CompileText("<test>", "test");
- BOOST_CHECK_THROW(expr->Evaluate(frame), ConfigError);
+ BOOST_CHECK_THROW(expr->Evaluate(frame), ScriptError);
delete expr;
expr = ConfigCompiler::CompileText("<test>", "null + 3");
delete expr;
expr = ConfigCompiler::CompileText("<test>", "__boost_test()");
- BOOST_CHECK_THROW(expr->Evaluate(frame), ConfigError);
+ BOOST_CHECK_THROW(expr->Evaluate(frame), ScriptError);
delete expr;
Object::Ptr self = new Object();
delete expr;
expr = ConfigCompiler::CompileText("<test>", "a = 3 b = 3");
- BOOST_CHECK_THROW(expr->Evaluate(frame), ConfigError);
+ BOOST_CHECK_THROW(expr->Evaluate(frame), ScriptError);
expr = ConfigCompiler::CompileText("<test>", "__function() { 3 }()");
BOOST_CHECK(expr->Evaluate(frame) == 3);