]> git.tdb.fi Git - libs/game.git/blobdiff - source/game/stage.cpp
Report which system caused invalid access
[libs/game.git] / source / game / stage.cpp
index 5663a71fadf8b36e1db21267724cf3d27e9530c2..f8dbd1a5b4fa21074b81d1f0d229d6f8e6ffe026 100644 (file)
@@ -1,4 +1,6 @@
 #include "stage.h"
+#include <msp/debug/demangle.h>
+#include <msp/strings/format.h>
 #include "accessguard.h"
 #include "camera.h"
 #include "root.h"
@@ -60,7 +62,17 @@ void Stage::tick(Time::TimeDelta dt)
                AccessGuard::BlockForScope _block;;
 #endif
                for(const auto &s: systems)
-                       s->tick(dt);
+               {
+                       System::Activator act(*s);
+                       try
+                       {
+                               s->tick(dt);
+                       }
+                       catch(const invalid_access &exc)
+                       {
+                               throw invalid_access(format("%s by %s", exc.what(), Debug::demangle(typeid(*s).name())));
+                       }
+               }
        }
 
        for(const auto &s: systems)