2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Nathan Letwory.
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/collada/ErrorHandler.cpp
26 #include "ErrorHandler.h"
29 #include "COLLADASaxFWLIError.h"
30 #include "COLLADASaxFWLSaxParserError.h"
31 #include "COLLADASaxFWLSaxFWLError.h"
33 #include "GeneratedSaxParserParserError.h"
37 #include "BLI_utildefines.h"
39 //--------------------------------------------------------------------
40 ErrorHandler::ErrorHandler() : mError(false)
44 //--------------------------------------------------------------------
45 ErrorHandler::~ErrorHandler()
49 //--------------------------------------------------------------------
50 bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error)
52 /* This method must return true when Collada should continue.
53 See https://github.com/KhronosGroup/OpenCOLLADA/issues/442
55 bool isWarning = false;
57 if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER) {
58 COLLADASaxFWL::SaxParserError *saxParserError = (COLLADASaxFWL::SaxParserError *) error;
59 const GeneratedSaxParser::ParserError& parserError = saxParserError->getError();
61 // Workaround to avoid wrong error
62 if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) {
63 if (STREQ(parserError.getElement(), "effect")) {
67 if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) {
68 if (!(STREQ(parserError.getElement(), "extra") &&
69 STREQ(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract")))
75 if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE) {
76 std::cout << "Couldn't open file" << std::endl;
79 std::cout << "Schema validation error: " << parserError.getErrorMessage() << std::endl;
81 else if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL) {
82 COLLADASaxFWL::SaxFWLError *saxFWLError = (COLLADASaxFWL::SaxFWLError *) error;
84 * Accept non critical errors as warnings (i.e. texture not found)
85 * This makes the importer more graceful, so it now imports what makes sense.
87 isWarning = (saxFWLError->getSeverity() == COLLADASaxFWL::IError::SEVERITY_ERROR_NONCRITICAL);
88 std::cout << "Sax FWL Error: " << saxFWLError->getErrorMessage() << std::endl;
91 std::cout << "opencollada error: " << error->getFullErrorMessage() << std::endl;