void SthenoCore::changeIIDOfService(UUIDPtr& sid, UUIDPtr& iid, UUIDPtr& newIid) throw (RuntimeException&, ServiceException&) { if (!isValid()) { throw RuntimeException(RuntimeException::INVALID_RUNTIME); } LocalServicePtr servicePtr; if (m_serviceMap.find(sid, servicePtr) == -1) { throw ServiceException(ServiceException::SERVICE_NOT_KNOWN); } servicePtr->setIID(iid, newIid); ServiceInstanceInfoPtr info; servicePtr->getInstancesOfServiceInfo(newIid, info); //info has the newIid MeshPtr meshPtr; try { getOverlay()->getMesh(meshPtr); } catch (OverlayException& ex) { throw RuntimeException(RuntimeException::INVALID_OVERLAY); } meshPtr->onServiceUpdateIID(sid, iid, newIid); }
SDL_Surface* Art::LoadTex(const char *fileName) { SDL_Surface *s = IMG_Load(fileName); if (!s) { char message[0xff]; sprintf(message, "Can not load resource file %s", fileName); throw RuntimeException(message); } return s; }
/*! Returns the MongoDB driver associated with the TMongoQuery object. */ const TMongoDriver *TMongoQuery::driver() const { #ifdef TF_NO_DEBUG return (const TMongoDriver *)database.driver(); #else const TMongoDriver *driver = dynamic_cast<const TMongoDriver *>(database.driver()); if (!driver) { throw RuntimeException("cast error", __FILE__, __LINE__); } return driver; #endif }
bool SthenoCore::getInstanceOfService(UUIDPtr& sid, UUIDPtr& iid, ServiceAbstractPtr& instance) throw (RuntimeException&, ServiceException&) { if (!isValid()) { throw RuntimeException(RuntimeException::INVALID_RUNTIME); } LocalServicePtr servicePtr; if (m_serviceMap.find(sid, servicePtr) == -1) { throw ServiceException("Service not found!"); } return servicePtr->getInstanceOfService(iid, instance); }
void LayeredConfiguration::setRaw(const std::string& key, const std::string& value) { for (ConfigList::iterator it = _configs.begin(); it != _configs.end(); ++it) { if (it->writeable) { it->pConfig->setRaw(key, value); return; } } throw RuntimeException("No writeable configuration object to store the property", key); }
void executive::ReconvergenceTFSoftware::eval_Exit( executive::CTAContext &context, const ir::PTXInstruction &instr) { if (stack.size() == 1 && context.active.count() == context.active.size()) { context.executionState = CTAContext::Exit; } else { throw RuntimeException("not all threads hit the exit: ", context.PC, instr); } }
bool ConcurrentMergeScheduler::anyUnhandledExceptions() { if (!allInstances) { boost::throw_exception(RuntimeException(L"setTestMode() was not called")); } SyncLock instancesLock(&allInstances); for (Collection<ConcurrentMergeSchedulerPtr>::iterator instance = allInstances.begin(); instance != allInstances.end(); ++instance) { (*instance)->sync(); } bool v = anyExceptions; anyExceptions = false; return v; }
int AtomSpace_getAtomByHandle( AtomSpace* this_ptr , UUID handle , char** type , char** name , UUID** out , int* out_len) { Handle h(handle); if(!h) throw InvalidParamException(TRACE_INFO, "Invalid Handler parameter."); const std::string &str = classserver().getTypeName(h->getType()); (*type) = (char*) malloc(sizeof(char) * (str.length()+1)); if(!(*type)) throw RuntimeException(TRACE_INFO,"Failed malloc."); std::strcpy(*type, str.c_str()); NodePtr ptr = NodeCast(h); if(ptr){//It is a node. const std::string &str = ptr->getName(); (*name) = (char*) malloc(sizeof(char) * (str.length()+1)); if(!(*name)) throw RuntimeException(TRACE_INFO,"Failed malloc."); std::strcpy(*name, str.c_str()); return 1; }else{//It is a link. LinkPtr lnk = LinkCast(h); if(!lnk) throw RuntimeException(TRACE_INFO,"Error in cast Link."); *out_len=lnk->getArity(); (*out) = (UUID*) malloc(sizeof(UUID) * (*out_len)); if(!(*out)) throw RuntimeException(TRACE_INFO,"Failed malloc."); int i; for(i=0;i<(*out_len);i++) (*out)[i]=lnk->getOutgoingAtom(i).value(); return 0; } }
void Image::loadData(std::unique_ptr<util::UseQueryResults> &rs) { if (!rs) throw RuntimeException("(ImageData:LoadData) UseQueryResult was NULL"); _image.release(); rs->getString("Name", _name); rs->getString("Path", _img_path); _location = rs->getInt("Location"); _docID = rs->getInt("docID"); _imgID = rs->getInt("idImages"); if (rs->hasField("Category")) _category = rs->getInt("Category"); }
JClass::JClass(QString clsName) { JNIEnv* env = *JVM::instance(); clsName.replace('.', '/'); QByteArray name = clsName.toUtf8(); jclass obj = env->FindClass(name.constData()); if (!obj) throw RuntimeException(QObject::tr("Java class %1 not found or failed to load").arg(clsName)); m_class = (jclass) env->NewGlobalRef(obj); env->DeleteLocalRef(obj); }
void Win32::unload() { if(m_handle != 0) { BOOL result; result = FreeLibrary(m_handle); if(!result) { throw RuntimeException("Module unload failed."); } m_handle = 0; } }
void VM::ForInit(Value *var, Value *limit, Value *step) { if (var->type_ != ValueT_Number) { auto pos = GetCurrentInstructionPos(); throw RuntimeException(pos.first, pos.second, var, "'for' init", "number"); } if (limit->type_ != ValueT_Number) { auto pos = GetCurrentInstructionPos(); throw RuntimeException(pos.first, pos.second, limit, "'for' limit", "number"); } if (step->type_ != ValueT_Number) { auto pos = GetCurrentInstructionPos(); throw RuntimeException(pos.first, pos.second, step, "'for' step", "number"); } }
/*! \~english Returns the authenticity token. \~japanese HTTPリクエストの正当性を検証するためのトークンを返す */ QByteArray TActionController::authenticityToken() const { if (Tf::app()->appSettings().value(STORE_TYPE).toString().toLower() == QLatin1String("cookie")) { QString key = Tf::app()->appSettings().value(CSRF_PROTECTION_KEY).toString(); QByteArray csrfId = session().value(key).toByteArray(); if (csrfId.isEmpty()) { throw RuntimeException("CSRF protectionsession value is empty", __FILE__, __LINE__); } return csrfId; } else { return QCryptographicHash::hash(session().id() + Tf::app()->appSettings().value("Session.Secret").toByteArray(), QCryptographicHash::Sha1).toHex(); } }
bool SnowballFilter::incrementToken() { if (input->incrementToken()) { StringUtils::toUTF8(termAtt->termBuffer().get(), termAtt->termLength(), utf8Result); const sb_symbol* stemmed = sb_stemmer_stem(stemmer, utf8Result->result.get(), utf8Result->length); if (stemmed == NULL) { boost::throw_exception(RuntimeException(L"exception stemming word:" + termAtt->term())); } int32_t newlen = StringUtils::toUnicode(stemmed, sb_stemmer_length(stemmer), termAtt->termBuffer()); termAtt->setTermLength(newlen); return true; } else { return false; } }
TActionContext *TActionContext::current() { TActionContext *context = 0; switch ( Tf::app()->multiProcessingModule() ) { case TWebApplication::Thread: context = qobject_cast<TActionThread *>(QThread::currentThread()); if (!context) { throw RuntimeException("The current thread is not TActionThread", __FILE__, __LINE__); } break; case TWebApplication::Prefork: context = TActionForkProcess::currentContext(); if (!context) { throw RuntimeException("The current process is not TActionProcess", __FILE__, __LINE__); } default: break; } return context; }
void MockRAMDirectory::close() { SyncLock syncLock(this); if (!openFiles) { openFiles = MapStringInt::newInstance(); openFilesDeleted = HashSet<String>::newInstance(); } if (noDeleteOpenFile && !openFiles.empty()) { // RuntimeException instead of IOException because RAMDirectory does not throw IOException currently boost::throw_exception(RuntimeException(L"MockRAMDirectory: cannot close: there are still open files")); } }
void Darwin::unload() throw(RuntimeException) { if(m_handle != 0) { int result; result = dlclose(m_handle); if(result != 0) { std::string message(dlerror()); throw RuntimeException("Module unload failed. " + message); } m_handle = 0; } }
std::shared_ptr<ExpressionNode> FunctionNode::evaluate(Environment* e, const std::vector<std::shared_ptr<ExpressionNode> >& arguments) { if (argumentNames.size() != arguments.size()) { throw RuntimeException("cannot apply function"); } std::vector<std::unique_ptr<SubstituteRule> > rules; for (size_t i = 0; i < argumentNames.size(); i++) { rules.push_back(std::unique_ptr<SubstituteRule> (new SubstituteRule(argumentNames[i], arguments[i]))); } return equation.get()->substitute(rules)->evaluate(e); }
QByteArray TSessionManager::generateId() { QByteArray id; int i; for (i = 0; i < 3; ++i) { id = randomString(); if (findSession(id).isEmpty()) break; } if (i == 3) throw RuntimeException("Unable to generate a unique session ID", __FILE__, __LINE__); return id; }
void VM::CheckTableType(const Value *t, const Value *k, const char *op, const char *desc) const { if (t->type_ == ValueT_Table || (t->type_ == ValueT_UserData && t->user_data_->GetMetatable())) return ; auto ns = GetOperandNameAndScope(t); auto pos = GetCurrentInstructionPos(); auto key_name = k->type_ == ValueT_String ? k->str_->GetCStr() : "?"; auto op_desc = std::string(op) + " table key '" + key_name + "' " + desc; throw RuntimeException(pos.first, pos.second, t, ns.first, ns.second, op_desc.c_str()); }
OneMerge::OneMerge(SegmentInfosPtr segments, bool useCompoundFile) { mergeDocStores = false; optimize = false; registerDone = false; mergeGen = 0; isExternal = false; maxNumSegmentsOptimize = 0; aborted = false; if (segments->empty()) boost::throw_exception(RuntimeException(L"segments must include at least one segment")); this->segments = segments; this->useCompoundFile = useCompoundFile; }
Notification::Notification() : m_notif(0) { if (!notify_notification_new) { QLibrary lib("libnotify.so.1"); if (!lib.load()) throw RuntimeException(tr("Libnotify not found.")); *((void**) ¬ify_notification_new) = lib.resolve("notify_notification_new"); *((void**) ¬ify_notification_update) = lib.resolve("notify_notification_update"); *((void**) ¬ify_notification_show) = lib.resolve("notify_notification_set_timeout"); *((void**) ¬ify_notification_set_timeout) = lib.resolve("notify_notification_show"); } }
sp<Promise<sp<Boolean>>> ContextImpl::bindService(const sp<Intent>& service, const sp<ServiceConnection>& conn, int32_t flags) { if (service != nullptr && conn != nullptr) { if (mServiceConnections->containsKey(conn)) { return new Promise<sp<Boolean>>(sp<Boolean>(new Boolean(true))); } mServiceConnections->put(conn, service); class OnResultListener : public RemoteCallback::OnResultListener { public: OnResultListener(const wp<ContextImpl>& context, const sp<Intent>& service, const sp<ServiceConnection>& conn) : mContext(context), mService(service), mConn(conn) { } protected: void onResult(const sp<Bundle>& data) { sp<ContextImpl> context = mContext.get(); if (context != nullptr) { bool result = data->getBoolean("result"); if (result) { sp<IBinder> binder = data->getBinder("binder"); mConn->onServiceConnected(mService->getComponent(), binder); } else { Log::e(ContextImpl::TAG, "Cannot bind to service %s", mService->getComponent()->toShortString()->c_str()); } context->mServiceConnectionCallbacks->remove(getCallback()); } } private: wp<ContextImpl> mContext; const sp<Intent> mService; const sp<ServiceConnection> mConn; }; sp<RemoteCallback> callback = new RemoteCallback(new OnResultListener(this, service, conn), mHandler); mServiceConnectionCallbacks->add(callback); try { return mServiceManager->bindService(service, conn, flags, callback->asInterface()); } catch (const RemoteException& e) { throw RuntimeException("System failure", e); } } else { return new Promise<sp<Boolean>>(sp<Boolean>(new Boolean(false))); } }
/*! Returns the MongoDB driver associated with the TRedis object. */ const TRedisDriver *TRedis::driver() const { #ifdef TF_NO_DEBUG return (const TRedisDriver *)database.driver(); #else if (!database.driver()) { return nullptr; } const TRedisDriver *driver = dynamic_cast<const TRedisDriver *>(database.driver()); if (!driver) { throw RuntimeException("cast error", __FILE__, __LINE__); } return driver; #endif }
void SthenoCore::removeService(UUIDPtr& sid, UUIDPtr& iid) throw (RuntimeException&, ServiceException&) { if (!isValid()) { throw RuntimeException(RuntimeException::INVALID_RUNTIME); } LocalServicePtr localService; if (m_serviceMap.find(sid, localService) == -1) { throw ServiceException(ServiceException::SERVICE_NOT_KNOWN); } ServiceAbstractPtr sPtr; try { localService->removeServiceInstance(iid); } catch (ServiceException& ex) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)SthenoCore:removeService: error on getInstance!\n"))); throw ex; } }
ServiceClient* SthenoCore::getClient(const UUIDPtr& sid, const UUIDPtr& iid, ClientParamsPtr& clientParams) throw (RuntimeException&, ServiceException&) { if (!isValid()) { throw RuntimeException(RuntimeException::INVALID_RUNTIME); } printf("SthenoCore::getClient 1\n"); ServiceAbstract* sa = m_serviceFactory.getInstance(sid); printf("SthenoCore::getClient 2\n"); UserService* us = static_cast<UserService*> (sa); printf("SthenoCore::getClient 3\n"); ServiceClient* client = us->getClient(sid, iid, clientParams); printf("SthenoCore::getClient 4\n"); delete sa; printf("SthenoCore::getClient 5 %p\n", client); return client; }
int FloatValue_toRaw(FloatValuePtr ptr , char** valuetype , double* parameters) { const std::string & type = classserver().getTypeName(ptr->get_type()); *valuetype = (char*) malloc(sizeof(char) * (type.length()+1)); if(! *valuetype) throw RuntimeException(TRACE_INFO,"Failed malloc."); std::strcpy(*valuetype, type.c_str()); const std::vector<double> val = ptr->value(); std::copy(val.begin(),val.end(),parameters); return 0; }
void SthenoCore::getInstanceOfService(UUIDPtr& sid, UUIDPtr& iid, ServiceInstanceInfoPtr& info) throw (RuntimeException&, ServiceException&) { if (!isValid()) { throw RuntimeException(RuntimeException::INVALID_RUNTIME); } LocalServicePtr servicePtr; ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: SthenoCore::getInstanceOfService(sid,iid,info) - SID=%s IID=%s\n"), sid->toString().c_str(), iid->toString().c_str() )); if (m_serviceMap.find(sid, servicePtr) == -1) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)ERROR: SthenoCore::getInstanceOfService(sid,iid,info) - Error not found SID=%s\n"), sid->toString().c_str())); throw ServiceException(ServiceException::SERVICE_NOT_KNOWN); } //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)after ifo S=%s\n"), sid->toString().c_str())); servicePtr->getInstancesOfServiceInfo(iid, info); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: SthenoCore::getInstanceOfService(sid,iid,info) - Found SID=%s!!!\n"), sid->toString().c_str())); }
void Darwin::load() throw(RuntimeException) { if(m_handle == 0) { // Opens the dynamic library. #if BOOST_FILESYSTEM_VERSION > 2 m_handle = dlopen(getFullPath(true).string().c_str(), RTLD_LAZY|RTLD_GLOBAL); #else m_handle = dlopen(getFullPath(true).native_file_string().c_str(), RTLD_LAZY|RTLD_GLOBAL); #endif if(m_handle == 0) { std::string message(dlerror()); throw RuntimeException("Module load failed. " + message); } } }
int AtomSpace_getTruthValue( AtomSpace* this_ptr , UUID uuid , TruthValueType* tv_type , double* parameters ) { Handle h(uuid); if(!h) // Invalid UUID parameter. return -1; TruthValuePtr tv = h->getTruthValue(); switch(tv->getType()) { case SIMPLE_TRUTH_VALUE: { parameters[0]=tv->getMean(); parameters[1]=tv->getConfidence(); break; } case COUNT_TRUTH_VALUE: { parameters[0]=tv->getMean(); parameters[1]=tv->getCount(); parameters[2]=tv->getConfidence(); break; } case INDEFINITE_TRUTH_VALUE: { IndefiniteTruthValuePtr itv = std::static_pointer_cast<IndefiniteTruthValue>(tv); parameters[0]=itv->getMean(); parameters[1]=itv->getL(); parameters[2]=itv->getU(); parameters[3]=itv->getConfidenceLevel(); parameters[4]=itv->getDiff(); break; } case FUZZY_TRUTH_VALUE: { parameters[0]=tv->getMean(); parameters[1]=tv->getConfidence(); break; } case PROBABILISTIC_TRUTH_VALUE: { parameters[0]=tv->getMean(); parameters[1]=tv->getCount(); parameters[2]=tv->getConfidence(); break; } default: throw RuntimeException(TRACE_INFO, "Invalid TruthValue Type."); break; } *tv_type = tv->getType(); return 0; }