summaryrefslogtreecommitdiff
path: root/server/src/server.cc
diff options
context:
space:
mode:
authordeva <deva>2008-08-04 09:17:36 +0000
committerdeva <deva>2008-08-04 09:17:36 +0000
commitbd8221d2791718f02ab1d067c797c62b29da9106 (patch)
tree787ca9a8ed9c3b1274a7d187cbe54cd4e278e42b /server/src/server.cc
parentf49d29d2a4b9b7e5dd544915f9236ae08e0c1ddd (diff)
Added NotFound exception when trying to open a non-existing and non-empty macro.
Diffstat (limited to 'server/src/server.cc')
-rw-r--r--server/src/server.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/server/src/server.cc b/server/src/server.cc
index 27a6b9d..6f875b8 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -63,6 +63,12 @@ static std::string error_box(std::string message)
return errorbox;
}
+class NotFoundException : public Exception {
+public:
+ NotFoundException(Request &r)
+ : Exception("Macro " + r.macro + " not found in course " + r.course) {}
+};
+
static void connection(TCPSocket &socket)
{
socket.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
@@ -154,6 +160,8 @@ static void connection(TCPSocket &socket)
answer += templ->course.attributes["name"];
answer += "\">\n";
+ bool foundmacro = false;
+
// Generate the macro and return it to the client
std::vector< Macro >::iterator mi2 = templ->course.macroes.begin();
while(mi2 != templ->course.macroes.end()) {
@@ -162,11 +170,12 @@ static void connection(TCPSocket &socket)
answer += " <macro name=\"" + macro.attributes["name"] + "\" completed=";
if(db.checkMacro(transaction.cpr, macro.attributes["name"])) answer += "\"true\"";
else answer += "\"false\"";
- // answer += " resume=\"" + macro.attributes["resume"] + "\"";
answer += ">\n";
if(macro.attributes["name"] == request.macro) {
+ foundmacro = true;
+
MacroParser mp(request.macro);
mp.parse();
Macro *m = mp.getMacro();
@@ -189,9 +198,14 @@ static void connection(TCPSocket &socket)
}
answer += " </macro>\n";
mi2++;
+
}
+ if(foundmacro == false && request.macro != "")
+ throw NotFoundException(request);
+
answer += " </course>\n";
+
socket.write(answer);
i++;
}