summaryrefslogtreecommitdiff
path: root/src/LuaTask.cc
diff options
context:
space:
mode:
authorNicolas Noble <nnoble@blizzard.com>2013-07-24 14:23:25 -0700
committerNicolas Noble <nnoble@blizzard.com>2013-07-24 14:23:25 -0700
commit712b4bed9973c60b5c139f98e51ed804ce8a628d (patch)
tree5a634d54a49d71e1dc6091092d8a8f763403446b /src/LuaTask.cc
parente37ef65aaa42e790a741c15dbae9b83e9c04cd3a (diff)
Better exception handling support for Lua.
Diffstat (limited to 'src/LuaTask.cc')
-rw-r--r--src/LuaTask.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/LuaTask.cc b/src/LuaTask.cc
index 12d4435..fc92cdf 100644
--- a/src/LuaTask.cc
+++ b/src/LuaTask.cc
@@ -60,6 +60,9 @@ void Balau::LuaTask::Do() {
try {
m_cell->run(L);
}
+ catch (GeneralException e) {
+ m_cell->m_exception = new GeneralException(e);
+ }
catch (...) {
m_cell->setError();
}
@@ -77,6 +80,20 @@ void Balau::LuaExecCell::exec(LuaMainTask * mainTask) {
Task::operationYield(&m_event);
}
+void Balau::LuaExecCell::throwError() throw (GeneralException) {
+ if (!gotError())
+ return;
+
+ if (m_exception) {
+ GeneralException copy(*m_exception);
+ delete m_exception;
+ m_exception = NULL;
+ throw copy;
+ } else {
+ throw GeneralException("Unknown error");
+ }
+}
+
void Balau::LuaExecString::run(Lua & L) {
L.load(m_str);
}