summaryrefslogtreecommitdiff
path: root/src/RpcMethod.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-06-15 00:19:07 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-06-15 00:19:07 +0900
commit2d92571cf9f171479163bd386b12c49e5805113a (patch)
treeff277be0f8851feb4929318568845c5238062f73 /src/RpcMethod.cc
parentba9673be1dcbf2a164a5899848230b6ff1b138f0 (diff)
Moved jsonRpc flag from RpcMethod to RpcRequest.
Now RpcMethod is stateless, so we can cache and reuse them.
Diffstat (limited to 'src/RpcMethod.cc')
-rw-r--r--src/RpcMethod.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/RpcMethod.cc b/src/RpcMethod.cc
index 96d05461..82897976 100644
--- a/src/RpcMethod.cc
+++ b/src/RpcMethod.cc
@@ -53,18 +53,17 @@ namespace aria2 {
namespace rpc {
RpcMethod::RpcMethod()
- : optionParser_(OptionParser::getInstance()),
- jsonRpc_(false)
+ : optionParser_(OptionParser::getInstance())
{}
RpcMethod::~RpcMethod() {}
SharedHandle<ValueBase> RpcMethod::createErrorResponse
-(const Exception& e)
+(const Exception& e, const RpcRequest& req)
{
SharedHandle<Dict> params = Dict::g();
- params->put((jsonRpc_ ? "code" : "faultCode"), Integer::g(1));
- params->put((jsonRpc_ ? "message" : "faultString"), std::string(e.what()));
+ params->put((req.jsonRpc ? "code" : "faultCode"), Integer::g(1));
+ params->put((req.jsonRpc ? "message" : "faultString"), std::string(e.what()));
return params;
}
@@ -73,9 +72,9 @@ RpcResponse RpcMethod::execute
{
try {
return RpcResponse(0, process(req, e), req.id);
- } catch(RecoverableException& e) {
- A2_LOG_DEBUG_EX(EX_EXCEPTION_CAUGHT, e);
- return RpcResponse(1, createErrorResponse(e), req.id);
+ } catch(RecoverableException& ex) {
+ A2_LOG_DEBUG_EX(EX_EXCEPTION_CAUGHT, ex);
+ return RpcResponse(1, createErrorResponse(ex, req), req.id);
}
}