diff --git a/code/Common/BaseImporter.cpp b/code/Common/BaseImporter.cpp index 0d7057066..1b8f9927a 100644 --- a/code/Common/BaseImporter.cpp +++ b/code/Common/BaseImporter.cpp @@ -134,12 +134,12 @@ aiScene *BaseImporter::ReadFile(Importer *pImp, const std::string &pFile, IOSyst // 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 ) { - // extract error description m_ErrorText = "Internal error"; ASSIMP_LOG_ERROR(err.what()); - m_internalException = std::current_exception(); + m_exception = std::current_exception(); return nullptr; } diff --git a/code/Common/Importer.cpp b/code/Common/Importer.cpp index de72d3bc8..38eb63f40 100644 --- a/code/Common/Importer.cpp +++ b/code/Common/Importer.cpp @@ -387,7 +387,7 @@ void Importer::FreeScene( ) { pimpl->mScene = nullptr; pimpl->mErrorString = ""; - pimpl->mInternalException = std::exception_ptr(); + pimpl->mException = std::exception_ptr(); ASSIMP_END_EXCEPTION_REGION(void); } @@ -400,11 +400,11 @@ const char* Importer::GetErrorString() const { return pimpl->mErrorString.c_str(); } -const std::exception_ptr& Importer::GetInternalException() const { +const std::exception_ptr& Importer::GetException() const { ai_assert(nullptr != pimpl); // Must remain valid as long as ReadFile() or FreeFile() are not called - return pimpl->mInternalException; + return pimpl->mException; } // ------------------------------------------------------------------------------------------------ @@ -434,7 +434,7 @@ aiScene* Importer::GetOrphanedScene() { pimpl->mScene = nullptr; pimpl->mErrorString = ""; // reset error string - pimpl->mInternalException = std::exception_ptr(); + pimpl->mException = std::exception_ptr(); ASSIMP_END_EXCEPTION_REGION(aiScene*); return s; @@ -511,7 +511,7 @@ const aiScene* Importer::ReadFileFromMemory( const void* pBuffer, ReadFile(fbuff,pFlags); SetIOHandler(io); - ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString, pimpl->mInternalException); + ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString, pimpl->mException); return pimpl->mScene; } @@ -718,7 +718,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) { // if failed, extract the error string else if( !pimpl->mScene) { pimpl->mErrorString = imp->GetErrorText(); - pimpl->mInternalException = imp->GetInternalException(); + pimpl->mException = imp->GetException(); } // clear any data allocated by post-process steps @@ -743,7 +743,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) { #endif // ! ASSIMP_CATCH_GLOBAL_EXCEPTIONS // either successful or failure - the pointer expresses it anyways - ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString, pimpl->mInternalException); + ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString, pimpl->mException); return pimpl->mScene; } diff --git a/code/Common/Importer.h b/code/Common/Importer.h index b9c223429..df3686613 100644 --- a/code/Common/Importer.h +++ b/code/Common/Importer.h @@ -99,11 +99,11 @@ public: /** The error description, if there was one. In the case of a * failure not caused by a DeadlyImportError, mInternalException will - * carry the exception and this will be just "Internal error". */ + * carry the full details and this will be just "Internal error". */ std::string mErrorString; - /** Any exception which wasn't a DeadlyImportError */ - std::exception_ptr mInternalException; + /** Any exception which occurred */ + std::exception_ptr mException; /** List of integer properties */ IntPropertyMap mIntProperties; @@ -138,7 +138,7 @@ ImporterPimpl::ImporterPimpl() AI_NO_EXCEPT , mPostProcessingSteps() , mScene( nullptr ) , mErrorString() -, mInternalException() +, mException() , mIntProperties() , mFloatProperties() , mStringProperties() diff --git a/include/assimp/BaseImporter.h b/include/assimp/BaseImporter.h index 946a9da7c..114531385 100644 --- a/include/assimp/BaseImporter.h +++ b/include/assimp/BaseImporter.h @@ -151,12 +151,11 @@ public: } // ------------------------------------------------------------------- - /** Returns the exception of the last non-DeadlyImportError that occurred. - * @return A description of the last error that occurred. An empty - * string if there was no error. + /** Returns the exception of the last exception that occurred. + * @return The last exception that occurred. */ - const std::exception_ptr& GetInternalException() const { - return m_internalException; + const std::exception_ptr& GetException() const { + return m_exception; } // ------------------------------------------------------------------- @@ -423,8 +422,8 @@ protected: /// Error description when a DeadlyImportError occurred during import. /// In case of other errors, this will just be "Internal error" std::string m_ErrorText; - /// Any exception which wasn't due to the asset being incorrect. - std::exception_ptr m_internalException; + /// An exception which occurred. + std::exception_ptr m_exception; /// Currently set progress handler. ProgressHandler *m_progress; }; diff --git a/include/assimp/Exceptional.h b/include/assimp/Exceptional.h index 7d010142c..2e02b72e6 100644 --- a/include/assimp/Exceptional.h +++ b/include/assimp/Exceptional.h @@ -140,15 +140,16 @@ struct ExceptionSwallower { { \ try { -#define ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(type, ASSIMP_END_EXCEPTION_REGION_errorString, ASSIMP_END_EXCEPTION_REGION_internalError) \ +#define ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(type, ASSIMP_END_EXCEPTION_REGION_errorString, ASSIMP_END_EXCEPTION_REGION_exception) \ } \ catch (const DeadlyImportError &e) { \ ASSIMP_END_EXCEPTION_REGION_errorString = e.what(); \ + ASSIMP_END_EXCEPTION_REGION_exception = std::current_exception(); \ return ExceptionSwallower()(); \ } \ catch (...) { \ ASSIMP_END_EXCEPTION_REGION_errorString = "Internal error"; \ - ASSIMP_END_EXCEPTION_REGION_internalError = std::current_exception(); \ + ASSIMP_END_EXCEPTION_REGION_exception = std::current_exception(); \ return ExceptionSwallower()(); \ } \ } diff --git a/include/assimp/Importer.hpp b/include/assimp/Importer.hpp index 40753d4c7..9078fbfe6 100644 --- a/include/assimp/Importer.hpp +++ b/include/assimp/Importer.hpp @@ -496,15 +496,13 @@ public: const char *GetErrorString() const; // ------------------------------------------------------------------- - /** Returns an internal exception if one occurred during import. + /** Returns an exception if one occurred during import. * - * Returns the last non-DeadlyImportError exception which occurred. - * @return The last exception which occurred which wasn't a - * DeadlyImportError. + * @return The last exception which occurred. * * @note The returned value remains valid until one of the * following methods is called: #ReadFile(), #FreeScene(). */ - const std::exception_ptr& GetInternalException() const; + const std::exception_ptr& GetException() const; // ------------------------------------------------------------------- /** Returns the scene loaded by the last successful call to ReadFile() diff --git a/test/unit/utImporter.cpp b/test/unit/utImporter.cpp index 05b0b1ba7..3d57461a5 100644 --- a/test/unit/utImporter.cpp +++ b/test/unit/utImporter.cpp @@ -334,7 +334,7 @@ TEST_F(ImporterTest, deadlyImportError) const aiScene* scene = pImp->ReadFile("deadlyImportError.fail", 0); EXPECT_EQ(scene, nullptr); EXPECT_STREQ(pImp->GetErrorString(), "Deadly import error test"); - EXPECT_EQ(pImp->GetInternalException(), std::exception_ptr()); + EXPECT_NE(pImp->GetException(), std::exception_ptr()); } TEST_F(ImporterTest, stdException) @@ -344,10 +344,10 @@ TEST_F(ImporterTest, stdException) const aiScene* scene = pImp->ReadFile("stdException.fail", 0); EXPECT_EQ(scene, nullptr); EXPECT_STREQ(pImp->GetErrorString(), "Internal error"); - EXPECT_NE(pImp->GetInternalException(), std::exception_ptr()); + EXPECT_NE(pImp->GetException(), std::exception_ptr()); try { - std::rethrow_exception(pImp->GetInternalException()); + std::rethrow_exception(pImp->GetException()); } catch(const std::exception& e) { @@ -367,10 +367,10 @@ TEST_F(ImporterTest, unexpectedException) EXPECT_EQ(scene, nullptr); EXPECT_STREQ(pImp->GetErrorString(), "Internal error"); - ASSERT_NE(pImp->GetInternalException(), std::exception_ptr()); + ASSERT_NE(pImp->GetException(), std::exception_ptr()); try { - std::rethrow_exception(pImp->GetInternalException()); + std::rethrow_exception(pImp->GetException()); } catch(int x) {