From 09c15331c437318c7e64ee060231fb77270443a8 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Sun, 15 Mar 2015 21:01:34 +0100 Subject: [PATCH] Improve error reporting during dump diffing. --- tools/assimp_cmd/CompareDump.cpp | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/tools/assimp_cmd/CompareDump.cpp b/tools/assimp_cmd/CompareDump.cpp index 33db0eb3d..5027a1fc4 100644 --- a/tools/assimp_cmd/CompareDump.cpp +++ b/tools/assimp_cmd/CompareDump.cpp @@ -257,16 +257,32 @@ private: /* read from both streams simult.*/ template void read(T& filla,T& fille) { if(1 != fread(&filla,sizeof(T),1,actual)) { - throw compare_fails_exception("Unexpected EOF reading ACTUAL"); + EOFActual(); } if(1 != fread(&fille,sizeof(T),1,expect)) { - throw compare_fails_exception("Unexpected EOF reading EXPECT"); + EOFExpect(); } } - private: + void EOFActual() { + std::stringstream ss; + throw compare_fails_exception((ss + << "Unexpected EOF reading ACTUAL.\nCurrent position in scene hierarchy is " + << print_hierarchy(),ss.str().c_str() + )); + } + + void EOFExpect() { + std::stringstream ss; + throw compare_fails_exception((ss + << "Unexpected EOF reading EXPECT.\nCurrent position in scene hierarchy is " + << print_hierarchy(),ss.str().c_str() + )); + } + + FILE *const actual, *const expect; typedef std::map PerChunkCounter; @@ -290,10 +306,10 @@ template <> void comparer_context :: read(aiString& filla,aiString& fi read(lena,lene); if(lena && 1 != fread(&filla.data,lena,1,actual)) { - throw compare_fails_exception("Unexpected EOF reading ACTUAL"); + EOFActual(); } if(lene && 1 != fread(&fille.data,lene,1,expect)) { - throw compare_fails_exception("Unexpected EOF reading ACTUAL"); + EOFExpect(); } fille.data[fille.length=static_cast(lene)] = '\0'; @@ -487,7 +503,7 @@ private: res|=fread(&actual.second,4,1,ctx.get_actual()) <<3u; if(res!=0xf) { - ctx.failure("I/OError reading chunk head, dumps are not well-defined",""); + ctx.failure("IO Error reading chunk head, dumps are malformed",""); } if (current.first != actual.first) { @@ -504,7 +520,7 @@ private: if (current.first != actual.first) { std::stringstream ss; ctx.failure((ss - <<"Chunk lenghts do not match. EXPECT: " + <<"Chunk lengths do not match. EXPECT: " <