#define EXTRA_LINES 2
-void icinga::ShowCodeFragment(std::ostream& out, const DebugInfo& di, bool verbose)
+void icinga::ShowCodeLocation(std::ostream& out, const DebugInfo& di, bool verbose)
{
if (di.Path.IsEmpty())
return;
+ out << "Location: " << di << "\n";
+
std::ifstream ifs;
ifs.open(di.Path.CStr(), std::ifstream::in);
I2_BASE_API DebugInfo DebugInfoRange(const DebugInfo& start, const DebugInfo& end);
-I2_BASE_API void ShowCodeFragment(std::ostream& out, const DebugInfo& di, bool verbose = true);
+I2_BASE_API void ShowCodeLocation(std::ostream& out, const DebugInfo& di, bool verbose = true);
}
const ValidationError *vex = dynamic_cast<const ValidationError *>(&ex);
if (message.IsEmpty())
- result << boost::diagnostic_information(ex);
+ result << boost::diagnostic_information(ex) << "\n";
else
- result << "Error: " << message;
+ result << "Error: " << message << "\n";
const ScriptError *dex = dynamic_cast<const ScriptError *>(&ex);
- if (dex && !dex->GetDebugInfo().Path.IsEmpty()) {
- result << "\nLocation:\n";
- ShowCodeFragment(result, dex->GetDebugInfo());
- }
+ if (dex && !dex->GetDebugInfo().Path.IsEmpty())
+ ShowCodeLocation(result, dex->GetDebugInfo());
if (vex) {
DebugInfo di;
di.LastColumn = message->Get(5);
}
- if (!di.Path.IsEmpty()) {
- result << "\nLocation:\n";
- ShowCodeFragment(result, di);
- }
+ if (!di.Path.IsEmpty())
+ ShowCodeLocation(result, di);
}
const user_error *uex = dynamic_cast<const user_error *>(&ex);
if (ex && ex->IsHandledByDebugger())
return;
- std::cout << "Breakpoint encountered " << di << "\n";
+ std::cout << "Breakpoint encountered.\n";
if (ex) {
- std::cout << "Exception: " << DiagnosticInformation(*ex);
+ std::cout << "Exception: " << DiagnosticInformation(*ex) << "\n";
ex->SetHandledByDebugger(true);
- }
+ } else
+ ShowCodeLocation(std::cout, di);
std::cout << "You can inspect expressions (such as variables) by entering them at the prompt.\n"
<< "To leave the debugger and continue the program use \"$continue\".\n";
}
}
} else {
- ShowCodeFragment(std::cout, di);
+ ShowCodeLocation(std::cout, di);
}
std::cout << ex.what() << "\n";
try {
#ifdef I2_DEBUG
/* std::ostringstream msgbuf;
- ShowCodeFragment(msgbuf, GetDebugInfo(), false);
+ ShowCodeLocation(msgbuf, GetDebugInfo(), false);
Log(LogDebug, "Expression")
<< "Executing:\n" << msgbuf.str();*/
#endif /* I2_DEBUG */