forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOcppError.h
More file actions
43 lines (36 loc) · 1.11 KB
/
Copy pathOcppError.h
File metadata and controls
43 lines (36 loc) · 1.11 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
// matth-x/MicroOcpp
// Copyright Matthias Akstaller 2019 - 2023
// MIT License
#ifndef OCPPERROR_H
#define OCPPERROR_H
#include <ArduinoJson.h>
#include <MicroOcpp/Core/Operation.h>
namespace MicroOcpp {
class NotImplemented : public Operation {
public:
const char *getErrorCode() override {
return "NotImplemented";
}
};
class MsgBufferExceeded : public Operation {
private:
size_t maxCapacity;
size_t msgLen;
public:
MsgBufferExceeded(size_t maxCapacity, size_t msgLen) : maxCapacity(maxCapacity), msgLen(msgLen) { }
const char *getErrorCode() override {
return "GenericError";
}
const char *getErrorDescription() override {
return "JSON too long or too many fields. Cannot deserialize";
}
std::unique_ptr<DynamicJsonDocument> getErrorDetails() override {
auto errDoc = std::unique_ptr<DynamicJsonDocument>(new DynamicJsonDocument(JSON_OBJECT_SIZE(2)));
JsonObject err = errDoc->to<JsonObject>();
err["max_capacity"] = maxCapacity;
err["msg_length"] = msgLen;
return errDoc;
}
};
} //end namespace MicroOcpp
#endif