[libcalamaresui] Improve explainYamlException

- overloads for common kinds of label
 - improve error reporting when reading settings and branding files
This commit is contained in:
Adriaan de Groot 2018-02-26 20:07:06 +01:00
parent e5ca8e091f
commit fdda0e14aa
4 changed files with 20 additions and 5 deletions

View File

@ -156,12 +156,12 @@ Settings::Settings( const QString& settingsFilePath,
}
catch ( YAML::Exception& e )
{
cWarning() << "YAML parser error " << e.what() << "in" << file.fileName();
CalamaresUtils::explainYamlException( e, ba, file.fileName() );
}
}
else
{
cWarning() << "Cannot read " << file.fileName();
cWarning() << "Cannot read settings file" << file.fileName();
}
s_instance = this;

View File

@ -114,6 +114,19 @@ void
explainYamlException( const YAML::Exception& e, const QByteArray& yamlData, const char *label )
{
cWarning() << "YAML error " << e.what() << "in" << label << '.';
explainYamlException( e, yamlData );
}
void
explainYamlException( const YAML::Exception& e, const QByteArray& yamlData, const QString& label )
{
cWarning() << "YAML error " << e.what() << "in" << label << '.';
explainYamlException( e, yamlData );
}
void
explainYamlException( const YAML::Exception& e, const QByteArray& yamlData )
{
if ( ( e.mark.line >= 0 ) && ( e.mark.column >= 0 ) )
{
// Try to show the line where it happened.
@ -172,7 +185,7 @@ loadYaml(const QString& filename, bool* ok)
}
catch ( YAML::Exception& e )
{
explainYamlException( e, ba, filename.toLatin1().constData() );
explainYamlException( e, ba, filename );
return QVariantMap();
}
}

View File

@ -57,6 +57,8 @@ QVariant yamlMapToVariant( const YAML::Node& mapNode );
* Uses @p label when labeling the data source (e.g. "netinstall data")
*/
void explainYamlException( const YAML::Exception& e, const QByteArray& data, const char *label );
void explainYamlException( const YAML::Exception& e, const QByteArray& data, const QString& label );
void explainYamlException( const YAML::Exception& e, const QByteArray& data );
} //ns

View File

@ -179,7 +179,7 @@ Branding::Branding( const QString& brandingFilePath,
}
catch ( YAML::Exception& e )
{
cWarning() << "YAML parser error " << e.what() << "in" << file.fileName();
CalamaresUtils::explainYamlException( e, ba, file.fileName() );
}
QDir translationsDir( componentDir.filePath( "lang" ) );
@ -192,7 +192,7 @@ Branding::Branding( const QString& brandingFilePath,
}
else
{
cWarning() << "Cannot read " << file.fileName();
cWarning() << "Cannot read branding file" << file.fileName();
}
s_instance = this;