void HandleException(ISafeRunnable::Pointer code, const ctkException& e) { try { static_cast<void>(dynamic_cast<const OperationCanceledException&> (e)); } catch (const std::bad_cast&) { // TODO logging try { // Policy.getLog() // .log( // new Status(IStatus.ERROR, Policy.JFACE, // IStatus.ERROR, // "Exception occurred", e)); //$NON-NLS-1$ qDebug() << e.printStackTrace(); } catch (...) { //e.printStackTrace(); BERRY_ERROR << "Exception occurred" << std::endl; } } code->HandleException(e); }
void SafeRunner::HandleException(ISafeRunnable::Pointer code, const ctkException& e) { try { Q_UNUSED(dynamic_cast<const OperationCanceledException&>(e)) } catch (const std::bad_cast& ) { // try to obtain the correct plug-in id for the bundle providing the safe runnable QString pluginId = CTKPluginActivator::getPluginId(static_cast<void*>(code.GetPointer())); if (pluginId.isEmpty()) pluginId = IRuntimeConstants::PI_RUNTIME(); QString message = QString("Problems occurred when invoking code from plug-in: \"%1\".").arg(pluginId); IStatus::Pointer status; try { const CoreException& coreExc = dynamic_cast<const CoreException&>(e); MultiStatus::Pointer multiStatus(new MultiStatus(pluginId, IRuntimeConstants::PLUGIN_ERROR, message, e, BERRY_STATUS_LOC)); multiStatus->Merge(coreExc.GetStatus()); status = multiStatus; } catch (const std::bad_cast&) { IStatus::Pointer tmpStatus(new Status(IStatus::ERROR_TYPE, pluginId, IRuntimeConstants::PLUGIN_ERROR, message, e, BERRY_STATUS_LOC)); status = tmpStatus; } // Make sure user sees the exception: if the log is empty, log the exceptions on stderr // if (!RuntimeLog.isEmpty()) // RuntimeLog.log(status); // else qWarning() << e.printStackTrace(); } code->HandleException(e); }
void WorkbenchPlugin::Log(const QString& clazz, const QString& methodName, const ctkException &t) { QString msg = QString("Exception in ") + clazz + "." + methodName + ": " + t.what(); WorkbenchPlugin::Log(msg, t); }
void WorkbenchPlugin::Log(const ctkException &exc) { QString str; QDebug dbg(&str); dbg << exc.printStackTrace(); BERRY_INFO << "LOG: " << str << std::endl; //inst->GetLog().log(exc); }
ctkException StatusUtil::GetCause(const ctkException& exc) { const ctkException* cause = exc.cause(); if (cause) { return *cause; } return exc; }
IStatus::Pointer StatusUtil::NewStatus(IStatus::Severity severity, const QString& message, const ctkException& exc, const Status::SourceLocation& sl) { QString statusMessage = message; if (message.isNull() || message.trimmed().isEmpty()) { if (exc.message().isEmpty()) { statusMessage = exc.what(); } else { statusMessage = exc.message(); } } IStatus::Pointer status(new Status(severity, PlatformUI::PLUGIN_ID(), severity, statusMessage, GetCause(exc), sl)); return status; }
// -------------------------------------------------------------------------- void ctkException::setCause(const ctkException& cause) { delete NestedException; NestedException = cause.clone(); }
// -------------------------------------------------------------------------- ctkException::ctkException(const QString& msg, const ctkException& cause) : Msg(msg), NestedException(cause.clone()) { }