From 8f893e36530d4868e2ff28b93381e54e535806d5 Mon Sep 17 00:00:00 2001 From: Malcolm Tyrrell Date: Thu, 20 Aug 2020 14:32:15 +0100 Subject: [PATCH] Actually, just keep the old behaviour for now. --- code/Common/BaseImporter.cpp | 7 +------ code/Common/Importer.h | 5 ++--- include/assimp/BaseImporter.h | 9 ++++++--- test/unit/utImporter.cpp | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp index 6f5e744a0..efeae03b1 100644 --- a/code/Common/BaseImporter.cpp +++ b/code/Common/BaseImporter.cpp @@ -130,14 +130,9 @@ aiScene *BaseImporter::ReadFile(Importer *pImp, const std::string &pFile, IOSyst // passes scale into ScaleProcess UpdateImporterScale(pImp); - } catch( const DeadlyImportError& err ) { + } catch( const std::exception &err ) { // extract error description m_ErrorText = err.what(); - ASSIMP_LOG_ERROR(m_ErrorText.c_str()); - m_Exception = std::current_exception(); - return nullptr; - } catch( const std::exception& err ) { - m_ErrorText = "Internal error"; ASSIMP_LOG_ERROR(err.what()); m_Exception = std::current_exception(); return nullptr; diff --git a/code/Common/Importer.h b/code/Common/Importer.h index df3686613..32a1780da 100644 --- a/code/Common/Importer.h +++ b/code/Common/Importer.h @@ -97,9 +97,8 @@ public: /** The imported data, if ReadFile() was successful, nullptr otherwise. */ aiScene* mScene; - /** The error description, if there was one. In the case of a - * failure not caused by a DeadlyImportError, mInternalException will - * carry the full details and this will be just "Internal error". */ + /** The error description, if there was one. In the case of an exception, + * mException will carry the full details. */ std::string mErrorString; /** Any exception which occurred */ diff --git a/include/assimp/BaseImporter.h b/include/assimp/BaseImporter.h index 3aaa80f69..a8239be8d 100644 --- a/include/assimp/BaseImporter.h +++ b/include/assimp/BaseImporter.h @@ -143,6 +143,8 @@ public: // ------------------------------------------------------------------- /** Returns the error description of the last error that occurred. + * If the error is due to a std::exception, this will return the message. + * Exceptions can also be accessed with GetException(). * @return A description of the last error that occurred. An empty * string if there was no error. */ @@ -152,6 +154,8 @@ public: // ------------------------------------------------------------------- /** Returns the exception of the last exception that occurred. + * Note: Exceptions are not the only source of error details, so GetErrorText + * should be consulted too. * @return The last exception that occurred. */ const std::exception_ptr& GetException() const { @@ -419,10 +423,9 @@ private: virtual void UpdateImporterScale(Importer *pImp); protected: - /// Error description when a DeadlyImportError occurred during import. - /// In case of other errors, this will just be "Internal error" + /// Error description in case there was one. std::string m_ErrorText; - /// An exception which occurred. + /// The exception, in case there was one. std::exception_ptr m_Exception; /// Currently set progress handler. ProgressHandler *m_progress; diff --git a/test/unit/utImporter.cpp b/test/unit/utImporter.cpp index 189b22bae..258d36fe5 100644 --- a/test/unit/utImporter.cpp +++ b/test/unit/utImporter.cpp @@ -343,7 +343,7 @@ TEST_F(ImporterTest, stdException) pImp->SetIOHandler(new TestIOSystem); const aiScene* scene = pImp->ReadFile("stdException.fail", 0); EXPECT_EQ(scene, nullptr); - EXPECT_STREQ(pImp->GetErrorString(), "Internal error"); + EXPECT_STREQ(pImp->GetErrorString(), "std::exception test"); EXPECT_NE(pImp->GetException(), std::exception_ptr()); try {