Make all exceptions available.
parent
b7c789da67
commit
e1a0163e7e
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -140,15 +140,16 @@ struct ExceptionSwallower<void> {
|
|||
{ \
|
||||
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<type>()(); \
|
||||
} \
|
||||
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<type>()(); \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue