InvalidTypeException.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarX::Core
19 * @author Kai Welke
20 * @date 2011 Humanoids Group, HIS, KIT
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24 
25 #pragma once
26 
27 #include <string>
28 
30 #include <ArmarXCore/interface/observers/VariantBase.h>
32 
34 {
35  class InvalidTypeException : public armarx::InvalidTypeException
36  {
37  public:
39  VariantTypeId typeId2,
40  const std::string& infoString = "")
41  {
42  std::stringstream sstream;
43  sstream << "Type1: " << Variant::typeToString(typeId1)
44  << " Type2: " << Variant::typeToString(typeId2);
45  if (!infoString.empty())
46  {
47  sstream << "\nInfo: " << infoString;
48  }
49  reason = sstream.str();
50  }
51 
52  InvalidTypeException(std::string typeId1,
53  std::string typeId2,
54  const std::string& infoString = "")
55  {
56  std::stringstream sstream;
57  sstream << "Type1: " << typeId1 << " Type2: " << typeId2;
58  if (!infoString.empty())
59  {
60  sstream << "\nInfo: " << infoString;
61  }
62  reason = sstream.str();
63  }
64 
65  ~InvalidTypeException() noexcept override
66  {
67  }
68 
69  std::string
70  ice_id() const override
71  {
72  return "armarx::exceptions::user::InvalidTypeException";
73  }
74  };
75 
76  class UnsupportedTypeException : public armarx::UnsupportedTypeException
77  {
78  public:
79  UnsupportedTypeException(VariantTypeId typeId, const std::string& infoString = "")
80  {
81  std::stringstream sstream;
82  sstream << "Unsupported Type: " << Variant::typeToString(typeId);
83  if (!infoString.empty())
84  {
85  sstream << "\nInfo: " << infoString;
86  }
87  reason = sstream.str();
88  }
89 
90  UnsupportedTypeException(const std::string& typeId, const std::string& infoString = "")
91  {
92  std::stringstream sstream;
93  sstream << "Unsupported Type: " << typeId;
94  if (!infoString.empty())
95  {
96  sstream << "\nInfo: " << infoString;
97  }
98  reason = sstream.str();
99  }
100 
101  ~UnsupportedTypeException() noexcept override
102  {
103  }
104 
105  std::string
106  ice_id() const override
107  {
108  return "armarx::exceptions::user::UnsupportedTypeException";
109  }
110  };
111 } // namespace armarx::exceptions::user
armarx::exceptions::user::InvalidTypeException::InvalidTypeException
InvalidTypeException(std::string typeId1, std::string typeId2, const std::string &infoString="")
Definition: InvalidTypeException.h:52
armarx::exceptions::user::InvalidTypeException::InvalidTypeException
InvalidTypeException(VariantTypeId typeId1, VariantTypeId typeId2, const std::string &infoString="")
Definition: InvalidTypeException.h:38
armarx::exceptions::user::UnsupportedTypeException::UnsupportedTypeException
UnsupportedTypeException(const std::string &typeId, const std::string &infoString="")
Definition: InvalidTypeException.h:90
armarx::exceptions::user::UnsupportedTypeException::~UnsupportedTypeException
~UnsupportedTypeException() noexcept override
Definition: InvalidTypeException.h:101
armarx::exceptions::user::InvalidTypeException
Definition: InvalidTypeException.h:35
armarx::exceptions::user::InvalidTypeException::~InvalidTypeException
~InvalidTypeException() noexcept override
Definition: InvalidTypeException.h:65
armarx::exceptions::user::UnsupportedTypeException::ice_id
std::string ice_id() const override
Definition: InvalidTypeException.h:106
armarx::Variant::typeToString
static std::string typeToString(VariantTypeId typeId)
Return the name of the registered type typeId.
Definition: Variant.cpp:848
armarx::exceptions::user::UnsupportedTypeException
Definition: InvalidTypeException.h:76
armarx::VariantTypeId
Ice::Int VariantTypeId
Definition: Variant.h:43
armarx::exceptions::user::InvalidTypeException::ice_id
std::string ice_id() const override
Definition: InvalidTypeException.h:70
armarx::exceptions::user::UnsupportedTypeException::UnsupportedTypeException
UnsupportedTypeException(VariantTypeId typeId, const std::string &infoString="")
Definition: InvalidTypeException.h:79
armarx::exceptions::user
Definition: NotImplementedYetException.h:32
Variant.h
Exception.h