From 9ebf3f2f105a34ba014c65330f7b6e6717388808 Mon Sep 17 00:00:00 2001 From: Arthur Moore Date: Sun, 19 Oct 2014 02:40:18 -0400 Subject: [PATCH] Provide more data when nifstream throws a runtime_error --- components/nif/niffile.hpp | 3 +++ components/nif/nifstream.hpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/components/nif/niffile.hpp b/components/nif/niffile.hpp index 108e455d7d..12e4d10c4f 100644 --- a/components/nif/niffile.hpp +++ b/components/nif/niffile.hpp @@ -74,6 +74,9 @@ public: } /// Number of roots size_t numRoots() const { return roots.size(); } + + /// Get the name of the file + std::string getFilename(){ return filename; } }; diff --git a/components/nif/nifstream.hpp b/components/nif/nifstream.hpp index 22d39b8d78..e62193a24e 100644 --- a/components/nif/nifstream.hpp +++ b/components/nif/nifstream.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "niftypes.hpp" @@ -142,7 +143,8 @@ public: std::vector str (length+1, 0); 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]; }