Parcourir la source

Actually, just keep the old behaviour for now.

Malcolm Tyrrell il y a 5 ans
Parent
commit
8f893e3653

+ 1 - 6
code/Common/BaseImporter.cpp

@@ -130,14 +130,9 @@ aiScene *BaseImporter::ReadFile(Importer *pImp, const std::string &pFile, IOSyst
         // passes scale into ScaleProcess
         // passes scale into ScaleProcess
         UpdateImporterScale(pImp);
         UpdateImporterScale(pImp);
 
 
-    } catch( const DeadlyImportError& err )    {
+    } catch( const std::exception &err ) {
         // extract error description
         // extract error description
         m_ErrorText = err.what();
         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());
         ASSIMP_LOG_ERROR(err.what());
         m_Exception = std::current_exception();
         m_Exception = std::current_exception();
         return nullptr;
         return nullptr;

+ 2 - 3
code/Common/Importer.h

@@ -97,9 +97,8 @@ public:
     /** The imported data, if ReadFile() was successful, nullptr otherwise. */
     /** The imported data, if ReadFile() was successful, nullptr otherwise. */
     aiScene* mScene;
     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;
     std::string mErrorString;
 
 
     /** Any exception which occurred */
     /** Any exception which occurred */

+ 6 - 3
include/assimp/BaseImporter.h

@@ -143,6 +143,8 @@ public:
 
 
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Returns the error description of the last error that occurred.
     /** 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
      * @return A description of the last error that occurred. An empty
      * string if there was no error.
      * string if there was no error.
      */
      */
@@ -152,6 +154,8 @@ public:
 
 
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Returns the exception of the last exception that occurred.
     /** 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. 
      * @return The last exception that occurred. 
      */
      */
     const std::exception_ptr& GetException() const {
     const std::exception_ptr& GetException() const {
@@ -419,10 +423,9 @@ private:
     virtual void UpdateImporterScale(Importer *pImp);
     virtual void UpdateImporterScale(Importer *pImp);
 
 
 protected:
 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;
     std::string m_ErrorText;
-    /// An exception which occurred.
+    /// The exception, in case there was one.
     std::exception_ptr m_Exception;
     std::exception_ptr m_Exception;
     /// Currently set progress handler.
     /// Currently set progress handler.
     ProgressHandler *m_progress;
     ProgressHandler *m_progress;

+ 1 - 1
test/unit/utImporter.cpp

@@ -343,7 +343,7 @@ TEST_F(ImporterTest, stdException)
     pImp->SetIOHandler(new TestIOSystem);
     pImp->SetIOHandler(new TestIOSystem);
     const aiScene* scene = pImp->ReadFile("stdException.fail", 0);
     const aiScene* scene = pImp->ReadFile("stdException.fail", 0);
     EXPECT_EQ(scene, nullptr);
     EXPECT_EQ(scene, nullptr);
-    EXPECT_STREQ(pImp->GetErrorString(), "Internal error");
+    EXPECT_STREQ(pImp->GetErrorString(), "std::exception test");
     EXPECT_NE(pImp->GetException(), std::exception_ptr());
     EXPECT_NE(pImp->GetException(), std::exception_ptr());
     try
     try
     {
     {