Changeset - 3a7c51612939
[Not reviewed]
0 1 0
Jan Kaluza - 10 years ago 2016-01-29 08:21:13
jkaluza@redhat.com
Catch boost::system::system_error when loading frontend
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
spectrum/src/main.cpp
Show inline comments
 
@@ -206,50 +206,51 @@ int mainloop() {
 
	}
 

	
 
	struct rlimit limit;
 
	limit.rlim_max = RLIM_INFINITY;
 
	limit.rlim_cur = RLIM_INFINITY;
 
	setrlimit(RLIMIT_CORE, &limit);
 
#endif
 

	
 
	Swift::SimpleEventLoop eventLoop;
 

	
 
	Swift::BoostNetworkFactories *factories = new Swift::BoostNetworkFactories(&eventLoop);
 
	UserRegistry userRegistry(config_, factories);
 

	
 
    
 
	Frontend *frontend = NULL;
 
	
 
	std::string frontend_name = CONFIG_STRING_DEFAULTED(config_, "service.frontend", "xmpp");
 
	std::string plugin_fc = "create_" + frontend_name + "_frontend_plugin";
 

	
 
	dll::shared_library self(dll::program_location());
 
	boost::function<boost::shared_ptr<FrontendPlugin>()> creator;
 

	
 
	try {
 
		creator = self.get_alias<boost::shared_ptr<FrontendPlugin>()>(plugin_fc);
 
	}
 
	catch (...) {
 
	} catch(boost::system::system_error& e) {
 
		LOG4CXX_ERROR(logger, "Error when loading frontend " << e.what());
 
		return -3;
 
	}
 

	
 
	if (!creator) {
 
		LOG4CXX_ERROR(logger, "Unknown Frontend name " << frontend_name);
 
		return -3;
 
	}
 

	
 
	frontend = creator()->createFrontend();
 

	
 
	Component transport(frontend, &eventLoop, factories, config_, NULL, &userRegistry);
 
	component_ = &transport;
 

	
 
	std::string error;
 
	StorageBackend *storageBackend = StorageBackend::createBackend(config_, error);
 
	if (storageBackend == NULL) {
 
		if (!error.empty()) {
 
			std::cerr << error << "\n";
 
			return -2;
 
		}
 
	}
 
	else if (!storageBackend->connect()) {
 
		std::cerr << "Can't connect to database. Check the log to find out the reason.\n";
 
		return -1;
 
	}
0 comments (0 inline, 0 general)