Provide more data when nifstream throws a runtime_error

loadfix
Arthur Moore 10 years ago
parent 9213067aee
commit 9ebf3f2f10

@ -74,6 +74,9 @@ public:
} }
/// Number of roots /// Number of roots
size_t numRoots() const { return roots.size(); } size_t numRoots() const { return roots.size(); }
/// Get the name of the file
std::string getFilename(){ return filename; }
}; };

@ -12,6 +12,7 @@
#include <OgreVector4.h> #include <OgreVector4.h>
#include <OgreMatrix3.h> #include <OgreMatrix3.h>
#include <OgreQuaternion.h> #include <OgreQuaternion.h>
#include <OgreStringConverter.h>
#include "niftypes.hpp" #include "niftypes.hpp"
@ -142,7 +143,8 @@ public:
std::vector<char> str (length+1, 0); std::vector<char> str (length+1, 0);
if(inp->read(&str[0], length) != length) if(inp->read(&str[0], length) != length)
throw std::runtime_error ("string length in NIF file does not match"); throw std::runtime_error (": String length in NIF file "+ file->getFilename() +" does not match! Expected length: "
+ Ogre::StringConverter::toString(length));
return &str[0]; return &str[0];
} }

Loading…
Cancel
Save