Blender V2.61 - r43446

ErrorHandler.cpp

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * Contributor(s): Nathan Letwory.
00019  *
00020  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00026 #include "ErrorHandler.h"
00027 #include <iostream>
00028 
00029 #include "COLLADASaxFWLIError.h"
00030 #include "COLLADASaxFWLSaxParserError.h"
00031 #include "COLLADASaxFWLSaxFWLError.h"
00032 
00033 #include "GeneratedSaxParserParserError.h"
00034 
00035 #include <string.h>
00036 
00037 //--------------------------------------------------------------------
00038 ErrorHandler::ErrorHandler() : mError(false)
00039 {
00040 }
00041 
00042 //--------------------------------------------------------------------
00043 ErrorHandler::~ErrorHandler()
00044 {
00045 }
00046 
00047 //--------------------------------------------------------------------
00048 bool ErrorHandler::handleError( const COLLADASaxFWL::IError* error )
00049 {
00050     mError = true;
00051     
00052     if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER )
00053     {
00054         COLLADASaxFWL::SaxParserError* saxParserError = (COLLADASaxFWL::SaxParserError*) error;
00055         const GeneratedSaxParser::ParserError& parserError = saxParserError->getError();
00056 
00057         // Workaround to avoid wrong error
00058         if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED)
00059         {
00060             if ( strcmp(parserError.getElement(), "effect") == 0 )
00061             {
00062                 mError = false;
00063             }
00064         }
00065         if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT)
00066         {
00067             if ( !((strcmp(parserError.getElement(), "extra") == 0) 
00068                 && (strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0)))
00069             {
00070                 mError = false;
00071             }
00072         }
00073 
00074         if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE)
00075         {
00076             std::cout << "Couldn't open file" << std::endl;
00077         }
00078 
00079         std::cout << "Schema validation error: " << parserError.getErrorMessage() << std::endl;
00080     }
00081     else if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL )
00082     {
00083         COLLADASaxFWL::SaxFWLError* saxFWLError = (COLLADASaxFWL::SaxFWLError*) error;
00084         std::cout << "Sax FWL Error: " << saxFWLError->getErrorMessage() << std::endl;
00085     }
00086     return false;
00087 }