From 4edae3f518353bb21a02fcda2dfcff83c5a72fc3 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 26 Jan 2012 12:08:39 +0100 Subject: New onCommit scripting system. --- server/src/client_connection.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'server/src/client_connection.cc') diff --git a/server/src/client_connection.cc b/server/src/client_connection.cc index b9d17b9..c3de7b0 100644 --- a/server/src/client_connection.cc +++ b/server/src/client_connection.cc @@ -108,6 +108,7 @@ void ClientConnection::nocommit(Session *session) } void ClientConnection::commit(Session *session) + throw(LUAScript::Exception, Journal::Exception) { if(docommit) { if(session->isReadonly()) { // Commit of an empty session discards it. @@ -117,7 +118,13 @@ void ClientConnection::commit(Session *session) DEBUG(connection, "Commit (%s)\n", session->id().c_str()); std::string sid = session->id(); - session->commit(); + try { + session->commit(); + } catch(LUAScript::Exception &e) { + throw e; + } catch(Journal::Exception &e) { + throw e; + } env.sessions.deleteSession(sid); sessionid = ""; docommit = false; @@ -208,7 +215,15 @@ bool ClientConnection::handle() response = handleTransaction(request, transaction, env, *session); } - commit(session); + try { + commit(session); + } catch(LUAScript::Exception &e) { + response = error_box(xml_encode(e.msg)); + return true; + } catch(Journal::Exception &e) { + response = error_box(xml_encode(e.msg)); + return true; + } nocommit(session); discard(session); -- cgit v1.2.3