improve error message when datasource plugin is not available

This commit is contained in:
Dane Springmeyer 2012-10-30 11:00:24 -07:00
parent a62e791d73
commit 10f6fbc731

View file

@ -36,6 +36,7 @@
// stl // stl
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <sstream>
#include <stdexcept> #include <stdexcept>
namespace mapnik { namespace mapnik {
@ -73,8 +74,17 @@ datasource_ptr datasource_cache::create(const parameters& params, bool bind)
std::map<std::string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(*type); std::map<std::string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(*type);
if ( itr == plugins_.end() ) if ( itr == plugins_.end() )
{ {
throw config_error(std::string("Could not create datasource. No plugin ") + std::ostringstream s;
"found for type '" + * type + "' (searched in: " + plugin_directories() + ")"); s << "Could not create datasource for type: '" << *type << "'";
if (plugin_directories_.empty())
{
s << " (no datasource plugin directories have been successfully registered)";
}
else
{
s << " (searched for datasource plugins in '" << plugin_directories() << "')";
}
throw config_error(s.str());
} }
if ( ! itr->second->handle()) if ( ! itr->second->handle())