当前位置: 首页>>代码示例>>C++>>正文


C++ Exception::message方法代码示例

本文整理汇总了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());
    }
  }
开发者ID:gustin,项目名称:rubinius,代码行数:28,代码来源:environment.cpp

示例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;
}
开发者ID:asir6,项目名称:Colt,代码行数:13,代码来源:CompilerOutputter.cpp

示例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;
  }
开发者ID:stormbrew,项目名称:rubinius,代码行数:7,代码来源:exception.cpp

示例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);
  }
开发者ID:stormbrew,项目名称:rubinius,代码行数:8,代码来源:exception.cpp

示例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()); }
}
开发者ID:dreamsxin,项目名称:WebCpp,代码行数:46,代码来源:RequestError.cpp

示例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);
}
开发者ID:dcowgill,项目名称:ares,代码行数:10,代码来源:exception.cpp

示例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;
}
开发者ID:sfegan,项目名称:serial_tracking,代码行数:10,代码来源:Message.cpp

示例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();
}
开发者ID:taohonker,项目名称:Ovito,代码行数:19,代码来源:Application.cpp

示例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;
  }
开发者ID:stormbrew,项目名称:rubinius,代码行数:20,代码来源:exception.cpp

示例10: showErrorMessage

void MainWindow::showErrorMessage(Exception &ex) {
    showErrorMessage(ex.message());
}
开发者ID:NielsHolst,项目名称:UniSim,代码行数:3,代码来源:main_window.cpp

示例11: exc_message

  static Handle exc_message(State& S, Handle recv, Arguments& args) {
    Exception* exc = recv->exception();

    return handle(S, exc->message());
  }
开发者ID:benolee,项目名称:marius,代码行数:5,代码来源:environment.cpp

示例12:

Exception::Exception(Exception &e)
    : m_str()
{
    m_str.clear();
    m_str << e.message();
}
开发者ID:Jim-Eckerlein,项目名称:dlo,代码行数:6,代码来源:base.cpp

示例13: testConstructorEmpty

void ExceptionTest::testConstructorEmpty() {
    Exception exception;

    QCOMPARE(exception.what(), "");
    QCOMPARE(exception.message(), QString(""));
}
开发者ID:KDE,项目名称:ktutorial,代码行数:6,代码来源:ExceptionTest.cpp


注:本文中的Exception::message方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。