exceptions.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdexcept>
4
5#include <SimoxUtility/json/json.hpp>
6
7namespace armarx::viz::error
8{
9
10 /// Base exception class.
11 class ArvizReflectionError : public std::runtime_error
12 {
13 public:
14 ArvizReflectionError(const std::string& msg);
15 };
16
17 /// Indicates that a JSON document did not contain the type name.
19 {
20 public:
21 NoTypeNameEntryInJsonObject(const std::string& missingKey, const nlohmann::json& j);
22
23 private:
24 static std::string makeMsg(const std::string& missingKey, const nlohmann::json& j);
25 };
26
27 /// The TypeNameEntryAlreadyInJsonObject class
29 {
30 public:
31 TypeNameEntryAlreadyInJsonObject(const std::string& key,
32 const std::string& typeName,
33 const nlohmann::json& j);
34
35 private:
36 static std::string
37 makeMsg(const std::string& key, const std::string& typeName, const nlohmann::json& j);
38 };
39
40 /// Indicates that the type name in a JSON object did not match the type of the passed C++ object.
42 {
43 public:
44 TypeNameMismatch(const std::string& typeInJson, const std::string& typeOfObject);
45
46 private:
47 static std::string makeMsg(const std::string& typeInJson, const std::string& typeOfObject);
48 };
49
50 /// Indicates that there was no registered serializer for a type.
52 {
53 public:
54 NoSerializerForType(const std::string& typeName);
55 };
56
57 /// Indicates that there already was a serializer registered for a type when trying to
58 /// register a serializer
60 {
61 public:
62 SerializerAlreadyRegisteredForType(const std::string& typeName,
63 const std::vector<std::string>& acceptedTypes = {});
64
65 private:
66 static std::string makeMsg(const std::string& typeName,
67 const std::vector<std::string>& acceptedTypes);
68 };
69
70} // namespace armarx::viz::error
ArvizReflectionError(const std::string &msg)
NoSerializerForType(const std::string &typeName)
NoTypeNameEntryInJsonObject(const std::string &missingKey, const nlohmann::json &j)
SerializerAlreadyRegisteredForType(const std::string &typeName, const std::vector< std::string > &acceptedTypes={})
TypeNameEntryAlreadyInJsonObject(const std::string &key, const std::string &typeName, const nlohmann::json &j)
TypeNameMismatch(const std::string &typeInJson, const std::string &typeOfObject)