From eb8fbc12e2848baf01296eedad75f0d4fb870f79 Mon Sep 17 00:00:00 2001 From: pippijn Date: Tue, 17 Jul 2007 13:04:36 +0000 Subject: provide feedback to the user if json throws an exception git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7462 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_rpc_json.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/modules/m_rpc_json.cpp') diff --git a/src/modules/m_rpc_json.cpp b/src/modules/m_rpc_json.cpp index 1cbbcf254..5977eb36e 100644 --- a/src/modules/m_rpc_json.cpp +++ b/src/modules/m_rpc_json.cpp @@ -46,16 +46,16 @@ class ModuleRpcJson : public Module if (http->GetURI() == "/jsonrpc" && http->GetType() == "POST") { - std::string response_text; - try - { - json::rpc::process (http, response_text, http->GetPostData().c_str()); - } - catch (std::runtime_error &) - { - // ignore - } - data << response_text; + try + { + std::string response_text; + json::rpc::process (http, response_text, http->GetPostData().c_str()); + data << response_text; + } + catch (std::runtime_error &) + { + data << "{ \"result\": \"JSON Fault\", \"error\": \"Invalid RPC call\", \"id\": 1}"; + } /* Send the document back to m_httpd */ HTTPDocument response(http->sock, &data, 200, "X-Powered-By: m_rpc_json.so\r\n" -- cgit v1.3.1-10-gc9f91