-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy patherror.cpp
More file actions
60 lines (50 loc) · 1.24 KB
/
Copy patherror.cpp
File metadata and controls
60 lines (50 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright © 2011 Vinícius dos Santos Oliveira
/*!
@warning this file should be included only by responsehandler.cpp
*/
#include "responsehandler.h"
#include <qt-json/json.h>
JsonRPC::Error::Error(ErrorCode code) :
code(code)
{
switch (code) {
case PARSE_ERROR:
desc = "Invalid JSON was received by the server.";
break;
case INVALID_REQUEST:
desc = "The JSON sent is not a valid Request object.";
break;
case METHOD_NOT_FOUND:
desc = "The method does not exist / is not available.";
break;
case INVALID_PARAMS:
desc = "Invalid method parameter(s).";
break;
case INTERNAL_ERROR:
default:
this->code = NO_ERROR;
case NO_ERROR:
break;
}
}
JsonRPC::Error::Error(ErrorCode code, QString desc) :
code(code),
desc(desc)
{
}
JsonRPC::Error::operator QByteArray() const
{
return QtJson::Json::serialize(static_cast<QVariantMap>(*this));
}
JsonRPC::Error::operator QVariantMap() const
{
QVariantMap obj;
obj.insert("jsonrpc", "2.0");
{
QVariantMap errorObj;
errorObj.insert("code", int(code));
errorObj.insert("message", desc);
obj.insert("error", errorObj);
}
return obj;
}