本文整理汇总了C++中Exception::message方法的典型用法代码示例。如果您正苦于以下问题:C++ Exception::message方法的具体用法?C++ Exception::message怎么用?C++ Exception::message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::message方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run_file
void Environment::run_file(std::string file) {
if(!state->probe->nil_p()) state->probe->load_runtime(state, file);
std::ifstream stream(file.c_str());
if(!stream) throw std::runtime_error("Unable to open file to run");
CompiledFile* cf = CompiledFile::load(stream);
if(cf->magic != "!RBIX") throw std::runtime_error("Invalid file");
// TODO check version number
cf->execute(state);
if(!G(current_task)->exception()->nil_p()) {
// Reset the context so we can show the backtrace
// HACK need to use write barrier aware stuff?
Exception* exc = G(current_task)->exception();
G(current_task)->active(state, exc->context());
std::ostringstream msg;
msg << "exception detected at toplevel: ";
if(!exc->message()->nil_p()) {
msg << exc->message()->c_str();
}
msg << " (" << exc->klass()->name()->c_str(state) << ")";
Assertion::raise(msg.str().c_str());
}
}
示例2:
void
CompilerOutputter::printFailureMessage( TestFailure *failure )
{
m_stream << std::endl;
Exception *thrownException = failure->thrownException();
m_stream << thrownException->message().shortDescription() << std::endl;
std::string message = thrownException->message().details();
if ( m_wrapColumn > 0 )
message = StringTools::wrap( message, m_wrapColumn );
m_stream << message << std::endl;
}
示例3: make_exception
Exception* Exception::make_exception(STATE, Class* exc_class, const char* message) {
Exception* exc = state->new_object<Exception>(exc_class);
exc->message(state, String::create(state, message));
return exc;
}
示例4:
void Exception::Info::show(STATE, Object* self, int level) {
Exception* exc = as<Exception>(self);
class_header(state, self);
indent_attribute(++level, "message"); exc->message()->show(state, level);
indent_attribute(level, "locations"); exc->locations()->show_simple(state, level);
close_body(level);
}
示例5: exception
void RequestError::exception(Request* request, Exception& e)
{
int code = 500;
if (e.type() == "NotFound")
code = 404;
else if (e.type() == "Forbidden")
code = 403;
if (code == 404)
System::log("NotFound", e.message(), request->ip());
else if (code == 403)
System::log("Forbidden", e.message(), System::Warning, request->ip());
else
System::log("Exceptions",
String("“%1” exception: %2.").format({e.type(), e.message()}),
System::Warning, request->ip());
#ifndef DEBUG
if (!request->headersSent())
request->setStatus(code);
Template* tpl = new Template("Errors/" + String(code) + ".html",
nullptr, request);
tpl->render();
delete tpl;
return;
#endif
try
{
View tpl = new Template("Sys::Exception.html", nullptr, request);
tpl["exceptionName"] = e.type();
tpl["exceptionMessage"] = e.htmlMessage();
tpl["webcppVersion"] = System::get()->version();
tpl["serverName"] = request->env("SERVER_NAME", "");
loadStackTrace(e, dynamic_cast<Template*>(*tpl));
if (!request->headersSent())
request->setStatus(500);
tpl->render();
}
catch (const Exception& e2)
{ fallbackErrorPage(request, e, e2.type()); }
catch (const std::exception& e2)
{ fallbackErrorPage(request, e, typeid(e2).name()); }
}
示例6: Exception
Exception::Exception(Exception const& e)
: m_module(copy_string(e.m_module))
, m_code(e.m_code)
, m_message(copy_string(e.m_message ? e.m_message : e.message()))
, m_args(0)
, m_num_args(0)
, m_next(e.m_next ? new /*(nothrow)*/ Exception(*e.m_next) : 0) // FIXME re-enable nothrow
{
set_arguments(e.m_args, e.m_num_args);
}
示例7: throw
Message::Message(const Exception& e, DistributionRealm realm,
PayloadSignificance sig, bool highlight) throw():
m_hostname(s_this_hostname), m_origin(MO_LOCAL), m_zone(-1),
m_program(s_this_program), m_title(e.title()), m_realm(realm),
m_significance(sig), m_message_oss(e.message()), m_details_oss(e.details()),
m_function(e.function(highlight)), m_time()
{
m_time.tv_sec=e.time().tv_sec;
m_time.tv_usec=e.time().tv_usec;
}
示例8: guiExceptionHandler
/******************************************************************************
* Handler function for exceptions used in GUI mode.
******************************************************************************/
void Application::guiExceptionHandler(const Exception& exception)
{
exception.logError();
QMessageBox msgbox;
msgbox.setWindowTitle(tr("Error - %1").arg(QCoreApplication::applicationName()));
msgbox.setStandardButtons(QMessageBox::Ok);
msgbox.setText(exception.message());
msgbox.setIcon(QMessageBox::Critical);
if(exception.messages().size() > 1) {
QString detailText;
for(int i = 1; i < exception.messages().size(); i++)
detailText += exception.messages()[i] + "\n";
msgbox.setDetailedText(detailText);
}
msgbox.exec();
}
示例9: make_errno_exception
Exception* Exception::make_errno_exception(STATE, Class* exc_class, Object* reason) {
Exception* exc = state->new_object<Exception>(exc_class);
String* message = (String*)reason;
if(String* str = try_as<String>(exc_class->get_const(state, "Strerror"))) {
str = str->string_dup(state);
if(String* r = try_as<String>(reason)) {
str->append(state, " - ");
message = str->append(state, r);
} else {
message = str;
}
}
exc->message(state, message);
exc->set_ivar(state, state->symbol("@errno"),
exc_class->get_const(state, "Errno"));
return exc;
}
示例10: showErrorMessage
void MainWindow::showErrorMessage(Exception &ex) {
showErrorMessage(ex.message());
}
示例11: exc_message
static Handle exc_message(State& S, Handle recv, Arguments& args) {
Exception* exc = recv->exception();
return handle(S, exc->message());
}
示例12:
Exception::Exception(Exception &e)
: m_str()
{
m_str.clear();
m_str << e.message();
}
示例13: testConstructorEmpty
void ExceptionTest::testConstructorEmpty() {
Exception exception;
QCOMPARE(exception.what(), "");
QCOMPARE(exception.message(), QString(""));
}