summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-19 00:28:38 +0000
committerDavid Robillard <d@drobilla.net>2008-08-19 00:28:38 +0000
commitf63dcf61bc04cc276ed5ae63266bfb91e3b84d94 (patch)
treed35864a19dac83962244940e825ca99d481909d9 /src/libs/engine
parentcc8264c1368e6a3891022ddca7dcf2c79df5cf2d (diff)
downloadingen-f63dcf61bc04cc276ed5ae63266bfb91e3b84d94.tar.gz
ingen-f63dcf61bc04cc276ed5ae63266bfb91e3b84d94.tar.bz2
ingen-f63dcf61bc04cc276ed5ae63266bfb91e3b84d94.zip
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
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/HTTPEngineReceiver.cpp13
1 files changed, 11 insertions, 2 deletions
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 <cstdlib>
#include <cstdio>
#include <string>
+#include <boost/format.hpp>
#include "types.hpp"
#include <raul/SharedPtr.hpp>
#include <raul/AtomLiblo.hpp>
@@ -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> 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");