added JsonInternalErrorException

This commit is contained in:
badaix 2015-09-01 22:52:37 +02:00
parent 707f198a26
commit e05e2fdd9d
2 changed files with 18 additions and 51 deletions

View file

@ -130,54 +130,3 @@ Json JsonNotification::getJson(const std::string& method, Json data)
return notification; return notification;
} }
/*
if ((method == "get") || (method == "set"))
{
vector<string> params;
try
{
params = request["params"].get<vector<string>>();
}
catch (const exception& e)
{
throw JsonRpcException(e.what(), -32602);
}
if (method == "get")
{
//{"jsonrpc": "2.0", "method": "get", "params": ["status"], "id": 2}
//{"jsonrpc": "2.0", "method": "get", "params": ["status", "server"], "id": 2}
//{"jsonrpc": "2.0", "method": "get", "params": ["status", "client"], "id": 2}
//{"jsonrpc": "2.0", "method": "get", "params": ["status", "client", "MAC"], "id": 2}
vector<string> params = request["params"].get<vector<string>>();
for (auto s: params)
logO << s << "\n";
response["result"] = "???";//nullptr;
}
else if (method == "set")
{
//{"jsonrpc": "2.0", "method": "set", "params": ["volume", "0.9", "client", "MAC"], "id": 2}
//{"jsonrpc": "2.0", "method": "set", "params": ["active", "client", "MAC"], "id": 2}
response["result"] = "234";//nullptr;
}
}
else
throw JsonRpcException("method not found: \"" + method + "\"", -32601);
connection->send(response.dump());
*/
/*
Json response = {
{"jsonrpc", "2.0"},
{"id", id}
};
*/

View file

@ -131,6 +131,10 @@ public:
}; };
// -32601 Method not found The method does not exist / is not available.
// -32602 Invalid params Invalid method parameter(s).
// -32603 Internal error Internal JSON-RPC error.
class JsonMethodNotFoundException : public JsonRequestException class JsonMethodNotFoundException : public JsonRequestException
{ {
public: public:
@ -158,4 +162,18 @@ public:
}; };
class JsonInternalErrorException : public JsonRequestException
{
public:
JsonInternalErrorException(const JsonRequest& request) : JsonRequestException(request, "internal error", -32603)
{
}
JsonInternalErrorException(const JsonRequest& request, const std::string& message) : JsonRequestException(request, message, -32603)
{
}
};
#endif #endif