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 
8 namespace armarx::viz::error
9 {
10 
11  /// Base exception class.
12  class ArvizReflectionError : public std::runtime_error
13  {
14  public:
15  ArvizReflectionError(const std::string& msg);
16  };
17 
18 
19  /// Indicates that a JSON document did not contain the type name.
21  {
22  public:
23  NoTypeNameEntryInJsonObject(const std::string& missingKey, const nlohmann::json& j);
24  private:
25  static std::string makeMsg(const std::string& missingKey, const nlohmann::json& j);
26  };
27 
28 
29  /// The TypeNameEntryAlreadyInJsonObject class
31  {
32  public:
33  TypeNameEntryAlreadyInJsonObject(const std::string& key, const std::string& typeName,
34  const nlohmann::json& j);
35  private:
36  static std::string makeMsg(const std::string& key, const std::string& typeName,
37  const nlohmann::json& j);
38  };
39 
40 
41  /// Indicates that the type name in a JSON object did not match the type of the passed C++ object.
43  {
44  public:
45  TypeNameMismatch(const std::string& typeInJson, const std::string& typeOfObject);
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 
58  /// Indicates that there already was a serializer registered for a type when trying to
59  /// register a serializer
61  {
62  public:
63  SerializerAlreadyRegisteredForType(const std::string& typeName,
64  const std::vector<std::string>& acceptedTypes = {});
65  private:
66  static std::string makeMsg(const std::string& typeName, const std::vector<std::string>& acceptedTypes);
67  };
68 
69 }
armarx::viz::error::SerializerAlreadyRegisteredForType::SerializerAlreadyRegisteredForType
SerializerAlreadyRegisteredForType(const std::string &typeName, const std::vector< std::string > &acceptedTypes={})
Definition: exceptions.cpp:81
armarx::viz::error::ArvizReflectionError
Base exception class.
Definition: exceptions.h:12
armarx::viz::error::TypeNameEntryAlreadyInJsonObject
The TypeNameEntryAlreadyInJsonObject class.
Definition: exceptions.h:30
armarx::viz::error::NoSerializerForType::NoSerializerForType
NoSerializerForType(const std::string &typeName)
Definition: exceptions.cpp:77
armarx::viz::error
Definition: exceptions.cpp:8
armarx::viz::error::TypeNameEntryAlreadyInJsonObject::TypeNameEntryAlreadyInJsonObject
TypeNameEntryAlreadyInJsonObject(const std::string &key, const std::string &typeName, const nlohmann::json &j)
Definition: exceptions.cpp:46
armarx::viz::error::NoTypeNameEntryInJsonObject
Indicates that a JSON document did not contain the type name.
Definition: exceptions.h:20
armarx::viz::error::SerializerAlreadyRegisteredForType
Indicates that there already was a serializer registered for a type when trying to register a seriali...
Definition: exceptions.h:60
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:42
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:11
armarx::viz::error::TypeNameMismatch::TypeNameMismatch
TypeNameMismatch(const std::string &typeInJson, const std::string &typeOfObject)
Definition: exceptions.cpp:63