diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/server.cc | 16 |
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++; } |