//------------------------------
    bool SaxErrorHandler::handleError ( const COLLADASaxFWL::IError* error )
    {
        COLLADASaxFWL::IError::ErrorClass errorClass = error->getErrorClass ();
        switch ( errorClass )
        {
        case COLLADASaxFWL::IError::ERROR_SAXPARSER:
            {
                COLLADASaxFWL::SaxParserError* parserError = ( COLLADASaxFWL::SaxParserError* ) error;
                //std::cerr << "Error: " << parserError->getError ().getErrorMessage () << std::endl;
            }
            break;
        case COLLADASaxFWL::IError::ERROR_SAXFWL:
            {
                COLLADASaxFWL::SaxFWLError* fwlError = ( COLLADASaxFWL::SaxFWLError* ) error;
                String message = fwlError->getFullErrorMessage ();
                std::cerr << "Error: " << fwlError->getFullErrorMessage () << std::endl;
            }
            break;
        default:
            {
                std::cerr << "Unknown Error!" << std::endl;
                break;
            }
        }

        // Don't break parsing!
        return false;
    }
Пример #2
0
//--------------------------------------------------------------------
bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error)
{
	/* This method must return true when Collada should continue.
	 * See https://github.com/KhronosGroup/OpenCOLLADA/issues/442
	 */
	bool isWarning = false;

	if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER) {
		COLLADASaxFWL::SaxParserError *saxParserError = (COLLADASaxFWL::SaxParserError *) error;
		const GeneratedSaxParser::ParserError& parserError = saxParserError->getError();

		// Workaround to avoid wrong error
		if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) {
			if (STREQ(parserError.getElement(), "effect")) {
				isWarning = true;
			}
		}
		if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) {
			if (!(STREQ(parserError.getElement(), "extra") &&
			      STREQ(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract")))
			{
				isWarning = true;
			}
		}

		if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE) {
			std::cout << "Couldn't open file" << std::endl;
		}

		std::cout << "Schema validation error: " << parserError.getErrorMessage() << std::endl;
	}
	else if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL) {
		COLLADASaxFWL::SaxFWLError *saxFWLError = (COLLADASaxFWL::SaxFWLError *) error;
		/*
		 * Accept non critical errors as warnings (i.e. texture not found)
		 * This makes the importer more graceful, so it now imports what makes sense.
		 */
		isWarning = (saxFWLError->getSeverity() == COLLADASaxFWL::IError::SEVERITY_ERROR_NONCRITICAL);
		std::cout << "Sax FWL Error: " << saxFWLError->getErrorMessage() << std::endl;
	}
	else {
		std::cout << "opencollada error: " << error->getFullErrorMessage() << std::endl;
	}

	return isWarning;
}
Пример #3
0
//--------------------------------------------------------------------
bool ErrorHandler::handleError( const COLLADASaxFWL::IError* error )
{
	mError = true;
	
	if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER )
	{
		COLLADASaxFWL::SaxParserError* saxParserError = (COLLADASaxFWL::SaxParserError*) error;
		const GeneratedSaxParser::ParserError& parserError = saxParserError->getError();

		// Workaround to avoid wrong error
		if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED)
		{
			if ( strcmp(parserError.getElement(), "effect") == 0 )
			{
				mError = false;
			}
		}
		if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT)
		{
			if ( !((strcmp(parserError.getElement(), "extra") == 0) 
				&& (strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0)))
			{
				mError = false;
			}
		}

		if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE)
		{
			std::cout << "Couldn't open file" << std::endl;
		}

		std::cout << "Schema validation error: " << parserError.getErrorMessage() << std::endl;
	}
	else if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL )
	{
		COLLADASaxFWL::SaxFWLError* saxFWLError = (COLLADASaxFWL::SaxFWLError*) error;
		std::cout << "Sax FWL Error: " << saxFWLError->getErrorMessage() << std::endl;
	}
	else {
		std::cout << "opencollada error: " << error->getFullErrorMessage() << std::endl;
	}

	return false;
}