Merge branch 'improve-errors'

This commit is contained in:
Adriaan de Groot 2019-06-18 12:36:11 +02:00
commit 0a48696254
6 changed files with 68 additions and 29 deletions

View File

@ -64,17 +64,21 @@ Handler::Handler( const QString& implementation, const QString& url, const QStri
{ {
bool ok = false; bool ok = false;
m_type = handlerTypes().find( implementation, ok ); m_type = handlerTypes().find( implementation, ok );
#if !defined(QT_XML_LIB)
if ( m_type == Type::XML )
{
m_type = Type::None;
cWarning() << "GeoIP style XML is not supported in this version of Calamares.";
}
#endif
if ( !ok ) if ( !ok )
{ {
cWarning() << "GeoIP Style" << implementation << "is not recognized."; cWarning() << "GeoIP style" << implementation << "is not recognized.";
} }
else if ( m_type == Type::None )
{
cWarning() << "GeoIP style *none* does not do anything.";
}
#if !defined(QT_XML_LIB)
else if ( m_type == Type::XML )
{
m_type = Type::None;
cWarning() << "GeoIP style *xml* is not supported in this version of Calamares.";
}
#endif
} }
Handler::~Handler() Handler::~Handler()

View File

@ -80,6 +80,8 @@ public:
bool isValid() const { return m_type != Type::None; } bool isValid() const { return m_type != Type::None; }
Type type() const { return m_type; } Type type() const { return m_type; }
QString url() const { return m_url; }
QString selector() const { return m_selector; }
private: private:
Type m_type; Type m_type;

View File

@ -198,7 +198,7 @@ Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Ex
return; return;
} }
} }
cDebug() << "No config file found in" << Logger::DebugList( configCandidates ); cDebug() << "No config file for" << m_name << "found anywhere at" << Logger::DebugList( configCandidates );
} }

View File

@ -90,10 +90,14 @@ ModuleManager::doInit()
if ( success ) if ( success )
{ {
QFileInfo descriptorFileInfo( currentDir.absoluteFilePath( QLatin1Literal( "module.desc") ) ); QFileInfo descriptorFileInfo( currentDir.absoluteFilePath( QLatin1Literal( "module.desc") ) );
if ( ! ( descriptorFileInfo.exists() && descriptorFileInfo.isReadable() ) ) if ( !descriptorFileInfo.exists() )
{ {
cDebug() << Q_FUNC_INFO << "unreadable file: " cDebug() << "ModuleManager expected descriptor is missing:" << descriptorFileInfo.absoluteFilePath();
<< descriptorFileInfo.absoluteFilePath(); continue;
}
if ( !descriptorFileInfo.isReadable() )
{
cDebug() << "ModuleManager descriptor file is unreadable:" << descriptorFileInfo.absoluteFilePath();
continue; continue;
} }
@ -111,13 +115,14 @@ ModuleManager::doInit()
} }
else else
{ {
cWarning() << "Cannot cd into module directory " cWarning() << "ModuleManager module directory is not accessible:" << path << "/" << subdir;
<< path << "/" << subdir;
} }
} }
} }
else else
cDebug() << "ModuleManager bad search path" << path; {
cDebug() << "ModuleManager module search path does not exist:" << path;
}
} }
// At this point m_availableModules is filled with whatever was found in the // At this point m_availableModules is filled with whatever was found in the
// search paths. // search paths.

View File

@ -128,17 +128,25 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
CalamaresUtils::getString( geoip, "style" ), CalamaresUtils::getString( geoip, "style" ),
CalamaresUtils::getString( geoip, "url" ), CalamaresUtils::getString( geoip, "url" ),
CalamaresUtils::getString( geoip, "selector" ) ); CalamaresUtils::getString( geoip, "selector" ) );
if ( handler->type() != CalamaresUtils::GeoIP::Handler::Type::None )
{
auto* future = new FWString(); auto* future = new FWString();
connect( future, &FWString::finished, [view=this, f=future, h=handler]() connect( future, &FWString::finished, [view=this, f=future, h=handler]()
{ {
QString countryResult = f->future().result(); QString countryResult = f->future().result();
cDebug() << "GeoIP result for welcome=" << countryResult; cDebug() << "GeoIP result for welcome=" << countryResult;
view->setCountry( countryResult ); view->setCountry( countryResult, h );
f->deleteLater(); f->deleteLater();
delete h; delete h;
} ); } );
future->setFuture( handler->queryRaw() ); future->setFuture( handler->queryRaw() );
} }
else
{
// Would not produce useful country code anyway.
delete handler;
}
}
QString language = CalamaresUtils::getString( configurationMap, "languageIcon" ); QString language = CalamaresUtils::getString( configurationMap, "languageIcon" );
@ -156,12 +164,22 @@ WelcomeViewStep::checkRequirements()
return m_requirementsChecker->checkRequirements(); return m_requirementsChecker->checkRequirements();
} }
static inline void
logGeoIPHandler( CalamaresUtils::GeoIP::Handler* handler )
{
if ( handler )
{
cDebug() << Logger::SubEntry << "Obtained from" << handler->url() << " (" << static_cast<int>( handler->type() ) << handler->selector() << ')';
}
}
void void
WelcomeViewStep::setCountry( const QString& countryCode ) WelcomeViewStep::setCountry( const QString& countryCode, CalamaresUtils::GeoIP::Handler* handler )
{ {
if ( countryCode.length() != 2 ) if ( countryCode.length() != 2 )
{ {
cDebug() << "Unusable country code" << countryCode; cDebug() << "Unusable country code" << countryCode;
logGeoIPHandler( handler );
return; return;
} }
@ -169,6 +187,7 @@ WelcomeViewStep::setCountry( const QString& countryCode )
if ( c_l.first == QLocale::Country::AnyCountry ) if ( c_l.first == QLocale::Country::AnyCountry )
{ {
cDebug() << "Unusable country code" << countryCode; cDebug() << "Unusable country code" << countryCode;
logGeoIPHandler( handler );
return; return;
} }
else else

View File

@ -32,6 +32,14 @@
class WelcomePage; class WelcomePage;
class GeneralRequirements; class GeneralRequirements;
namespace CalamaresUtils
{
namespace GeoIP
{
class Handler;
}
} // namespace
class PLUGINDLLEXPORT WelcomeViewStep : public Calamares::ViewStep class PLUGINDLLEXPORT WelcomeViewStep : public Calamares::ViewStep
{ {
Q_OBJECT Q_OBJECT
@ -57,9 +65,10 @@ public:
/** @brief Sets the country that Calamares is running in. /** @brief Sets the country that Calamares is running in.
* *
* This (ideally) sets up language and locale settings that are right for * This (ideally) sets up language and locale settings that are right for
* the given 2-letter country code. * the given 2-letter country code. Uses the handler's information (if
* given) for error reporting.
*/ */
void setCountry( const QString& ); void setCountry( const QString&, CalamaresUtils::GeoIP::Handler* handler );
Calamares::RequirementsList checkRequirements() override; Calamares::RequirementsList checkRequirements() override;