#1666 CommandFile: Add command and argument name to error messages

This commit is contained in:
Jacob Støren
2017-06-29 16:29:50 +02:00
parent c25895bdad
commit bc0379d246
5 changed files with 16 additions and 5 deletions

View File

@@ -61,7 +61,9 @@ void RicfFieldReader<QString>::readFieldData(QString& fieldValue, QTextStream& i
{
// Unexpected start of string, Missing '"'
// Error message
errorMessageContainer->addError("String argument does not seem to be quoted. Missing the start '\"'");
errorMessageContainer->addError("String argument does not seem to be quoted. Missing the start '\"' in the \""
+ errorMessageContainer->currentArgument + "\" argument of the command: \""
+ errorMessageContainer->currentCommand + "\"" );
// Could interpret as unquoted text
}

View File

@@ -33,7 +33,10 @@ struct RicfFieldReader
inputStream >> fieldValue;
if (inputStream.status() == QTextStream::ReadCorruptData)
{
errorMessageContainer->addError("Argument value is unreadable");
errorMessageContainer->addError("Argument value is unreadable in the argument: \""
+ errorMessageContainer->currentArgument + "\" in the command: \""
+ errorMessageContainer->currentCommand + "\"" );
inputStream.setStatus( QTextStream::Ok);
}
}

View File

@@ -32,6 +32,8 @@ public:
void addWarning(const QString& message) { m_messages.push_back(std::make_pair(WARNING, message));}
void addError(const QString& message) { m_messages.push_back(std::make_pair(ERROR, message));}
QString currentCommand;
QString currentArgument;
std::vector<std::pair<MessageType, QString> > m_messages;
};

View File

@@ -74,7 +74,7 @@ void RicfObjectCapability::readFields(QTextStream& inputStream,
if ( currentChar != QChar('=') )
{
// Error message: Missing "=" after argument name
errorMessageContainer->addError("Can't find the '=' after the argument named: \"" + keyword);
errorMessageContainer->addError("Can't find the '=' after the argument named: \"" + keyword + "\" in the command: \"" + errorMessageContainer->currentCommand + "\"" );
fieldDataFound = false;
if (currentChar == QChar(')') )
{
@@ -99,7 +99,7 @@ void RicfObjectCapability::readFields(QTextStream& inputStream,
if ( readFields.count(keyword) )
{
// Warning message: Referenced the same argument several times
errorMessageContainer->addWarning("The argument: \"" + keyword + "\" is referenced several times." );
errorMessageContainer->addWarning("The argument: \"" + keyword + "\" is referenced several times in the command: \"" + errorMessageContainer->currentCommand + "\"" );
}
}
@@ -115,14 +115,16 @@ void RicfObjectCapability::readFields(QTextStream& inputStream,
if ( xmlFieldHandle->isIOReadable() )
{
errorMessageContainer->currentArgument = keyword;
rcfField->readFieldData(inputStream, objectFactory, errorMessageContainer);
errorMessageContainer->currentArgument = keyword;
}
}
else
{
// Error message: Unknown argument name
errorMessageContainer->addWarning("The argument: \"" + keyword + "\" does not exist.");
errorMessageContainer->addWarning("The argument: \"" + keyword + "\" does not exist in the command: \"" + errorMessageContainer->currentCommand + "\"");
}
}

View File

@@ -114,7 +114,9 @@ std::vector<RicfCommandObject*> RicfCommandFileReader::readCommands(QTextStream&
{
readCommands.push_back(cObj);
auto rcfCap = cObj->capability<RicfObjectCapability>();
errorMessageContainer->currentCommand = commandName;
rcfCap->readFields(inputStream, objectFactory, errorMessageContainer);
errorMessageContainer->currentCommand = "";
}
}