Example #1
0
Bool CCompiler::OnCompileFail( )
{
    CL_TRACE("Enter CCompiler::OnCompileFail");

    FileSystem::FileHandle compileLogFile = FileSystem::CreateFile(EFileType::E_FILE_TYPE_MEMORY);
    
    if( !compileLogFile->Open( m_compilerOutputFile, EAccesMode::E_ACCES_MODE_READ ) )
    {
        CL_ERROR( "failed to open file:[%s]", m_compilerOutputFile.GetBuffer() );
        return false;
    }

    u64 fileSize = compileLogFile->GetSize();
    CString fileContent;
    fileContent.Resize(fileSize);

    if( !compileLogFile->Read( fileContent.GetBuffer(), fileSize, 1 ) )
    {
        CL_ERROR( "failed to read file content for:[%s]" ,m_compilerOutputFile.GetBuffer() );
        return false;
    }

#define COMPILER_USE_FULL_DEVENV_OUTPUT

#if !defined(COMPILER_USE_FULL_DEVENV_OUTPUT)
    //replace CompilerDummy.cpp with our file
    CString slnCppFileName = GetSolutionCppFileRaw();
    CString sourceFileName = "CodSursa.cpp";

    CRegex regexReplace( slnCppFileName );
    fileContent = regexReplace.Replace( fileContent, sourceFileName);

    CL_TRACE("fileContent:\n[%s]\n=======================", fileContent.GetBuffer());
    //CL_ERROR("fileContent:\n[%s]\n=======================", fileContent.GetBuffer());

    const CString regexString = sourceFileName + "\\([0-9]+\\):.*error C[0-9]+:[^\n]*";
    CRegex errorRegex( regexString, true );
    CRegex::TCaptures errors;

    if( !errorRegex.Find( fileContent, errors ) )
    {
        CL_ERROR( "failed to find errors in file:[%s]",m_compilerOutputFile.GetBuffer() );
        return false;
    }

    for( u64 i=0; i<errors.GetSize(); i++ )
    {
        const CString& error = errors[i];
        m_compileErrors += error;
    }
#else
    m_compileErrors = fileContent;
#endif //COMPILER_USE_FULL_DEVENV_OUTPUT

    return true;    // The OnCompileFailed step succeeded;
}
Example #2
0
int WebClient::getEdition(
		const QString& email,
		const QString& password,
		QMessageBox& message,
		QWidget* w)
{
	QString responseJson;
	int edition = Unknown;
	try {
		responseJson = request(email, password);
	}
	catch (std::exception& e)
	{
		message.critical(
			w, "Error",
			tr("An error occurred while trying to sign in. "
			"Please contact the helpdesk, and provide the "
			"following details.\n\n%1").arg(e.what()));
		return edition;
	}

	QRegExp resultRegex(".*\"result\".*:.*(true|false).*");
	if (resultRegex.exactMatch(responseJson)) {
		QString boolString = resultRegex.cap(1);
		if (boolString == "true") {
			QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*");
			if (editionRegex.exactMatch(responseJson)) {
				QString e = editionRegex.cap(1);
				edition = e.toInt();
			}

			return edition;
		}
		else if (boolString == "false") {
			message.critical(
				w, "Error",
				tr("Login failed, invalid email or password."));

			return edition;
		}
	}
	else {
		QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*");
		if (errorRegex.exactMatch(responseJson)) {

			// replace "\n" with real new lines.
			QString error = errorRegex.cap(1).replace("\\n", "\n");
			message.critical(
				w, "Error",
				tr("Login failed, an error occurred.\n\n%1").arg(error));

			return edition;
		}
	}

	message.critical(
		w, "Error",
		tr("Login failed, an error occurred.\n\nServer response:\n\n%1")
		.arg(responseJson));

	return edition;
}