From f63dcf61bc04cc276ed5ae63266bfb91e3b84d94 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 19 Aug 2008 00:28:38 +0000 Subject: Return human-readable error messages in content of error responses. git-svn-id: http://svn.drobilla.net/lad/ingen@1439 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/HTTPEngineReceiver.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/libs') diff --git a/src/libs/engine/HTTPEngineReceiver.cpp b/src/libs/engine/HTTPEngineReceiver.cpp index 4d57843b..1b21e184 100644 --- a/src/libs/engine/HTTPEngineReceiver.cpp +++ b/src/libs/engine/HTTPEngineReceiver.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "types.hpp" #include #include @@ -110,6 +111,9 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const if (!Path::is_valid(path)) { soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); + const string& err = (boost::format("Bad path: %1%") % path).str(); + soup_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY, + err.c_str(), err.length()); return; } @@ -120,6 +124,9 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const Store::const_iterator start = store->find(path); if (start == store->end()) { soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND); + const string& err = (boost::format("No such object: %1%") % path).str(); + soup_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY, + err.c_str(), err.length()); return; } @@ -127,6 +134,8 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const SharedPtr serialiser = me->_engine.world()->serialiser; if (!serialiser) { soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR); + soup_message_set_response (msg, "text/plain", SOUP_MEMORY_STATIC, + "No serialiser available\n", 24); return; } @@ -137,8 +146,8 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const #endif // Serialise object - const string response = serialiser->to_string(start->second, "http://example.org", - GraphObject::Variables()); + const string response = serialiser->to_string(start->second, + "http://example.org", GraphObject::Variables()); #if 0 FILE* xhtml_file = fopen("/home/dave/ingen_ui.xhtml", "r"); -- cgit v1.2.1