exceptions.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdexcept>
4 
5 #include <SimoxUtility/json/json.hpp>
6 
7 namespace 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
armarx::viz::error::SerializerAlreadyRegisteredForType::SerializerAlreadyRegisteredForType
SerializerAlreadyRegisteredForType(const std::string &typeName, const std::vector< std::string > &acceptedTypes={})
Definition: exceptions.cpp:86
armarx::viz::error::ArvizReflectionError
Base exception class.
Definition: exceptions.h:11
armarx::viz::error::TypeNameEntryAlreadyInJsonObject
The TypeNameEntryAlreadyInJsonObject class.
Definition: exceptions.h:28
armarx::viz::error::NoSerializerForType::NoSerializerForType
NoSerializerForType(const std::string &typeName)
Definition: exceptions.cpp:81
armarx::viz::error
Definition: exceptions.cpp:7
armarx::viz::error::TypeNameEntryAlreadyInJsonObject::TypeNameEntryAlreadyInJsonObject
TypeNameEntryAlreadyInJsonObject(const std::string &key, const std::string &typeName, const nlohmann::json &j)
Definition: exceptions.cpp:47
armarx::viz::error::NoTypeNameEntryInJsonObject
Indicates that a JSON document did not contain the type name.
Definition: exceptions.h:18
armarx::viz::error::SerializerAlreadyRegisteredForType
Indicates that there already was a serializer registered for a type when trying to register a seriali...
Definition: exceptions.h:59
armarx::viz::error::TypeNameMismatch
Indicates that the type name in a JSON object did not match the type of the passed C++ object.
Definition: exceptions.h:41
armarx::viz::error::NoTypeNameEntryInJsonObject::NoTypeNameEntryInJsonObject
NoTypeNameEntryInJsonObject(const std::string &missingKey, const nlohmann::json &j)
Definition: exceptions.cpp:14
armarx::viz::error::NoSerializerForType
Indicates that there was no registered serializer for a type.
Definition: exceptions.h:51
armarx::viz::error::ArvizReflectionError::ArvizReflectionError
ArvizReflectionError(const std::string &msg)
Definition: exceptions.cpp:10
armarx::viz::error::TypeNameMismatch::TypeNameMismatch
TypeNameMismatch(const std::string &typeInJson, const std::string &typeOfObject)
Definition: exceptions.cpp:66