OSVR-Core
RoutingExceptions.h
Go to the documentation of this file.
1 
11 // Copyright 2014 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_RoutingExceptions_h_GUID_DDBD7E30_8C15_46AE_4221_1EB366EA079D
26 #define INCLUDED_RoutingExceptions_h_GUID_DDBD7E30_8C15_46AE_4221_1EB366EA079D
27 
28 // Internal Includes
29 // - none
30 
31 // Library/third-party includes
32 // - none
33 
34 // Standard includes
35 #include <stdexcept>
36 #include <string>
37 
38 namespace osvr {
39 namespace common {
43  namespace exceptions {
46  struct InvalidDeviceName : std::runtime_error {
47  InvalidDeviceName(std::string const &details)
48  : std::runtime_error(
49  "Attempted to add invalid device name to tree: " +
50  details) {}
51  };
52 
54  struct EmptyPathComponent : std::runtime_error {
55  EmptyPathComponent(std::string const &path)
56  : std::runtime_error(
57  "Cannot use a path with an empty component: " + path) {}
58  };
59 
61  struct ImpossibleParentPath : std::runtime_error {
63  : std::runtime_error("Cannot specify .. for parent path when "
64  "already at the root!") {}
65  };
66 
69  struct ForbiddenAbsolutePath : std::runtime_error {
71  : std::runtime_error(
72  "Cannot specify an absolute path in this context!") {}
73  };
74 
77  struct ForbiddenParentPath : std::runtime_error {
79  : std::runtime_error("Cannot specify .. in a parent path used "
80  "in this context!") {}
81  };
82 
84  struct EmptyPath : std::runtime_error {
85  EmptyPath()
86  : std::runtime_error("Cannot retrieve an empty path!") {}
87  };
88 
91  struct PathNotAbsolute : std::runtime_error {
92  PathNotAbsolute(std::string const &path)
93  : std::runtime_error(
94  "Provided path was not absolute (no leading slash): " +
95  path) {}
96  };
97 
101  namespace invariants {
102  struct InvariantError : std::runtime_error {
103  InvariantError(std::string const &msg)
104  : std::runtime_error("Path tree violated invariant: " +
105  msg) {}
106  };
107 
109  SensorMissingParent(std::string const &path = std::string())
110  : InvariantError("Sensor element missing a parent! " +
111  path) {}
112  };
115  std::string const &path = std::string())
116  : InvariantError("Sensor element does not have an "
117  "InterfaceElement parent! " +
118  path) {}
119  };
120 
122  InterfaceMissingParent(std::string const &path = std::string())
123  : InvariantError("Interface elements must have a "
124  "parent of some device type! " +
125  path) {}
126  };
127  } // namespace invariants
128 
129  } // namespace exceptions
130 } // namespace common
131 } // namespace osvr
132 #endif // INCLUDED_RoutingExceptions_h_GUID_DDBD7E30_8C15_46AE_4221_1EB366EA079D
Thrown when attempting to use a path with an empty component.
Definition: RoutingExceptions.h:54
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
Definition: RoutingExceptions.h:102
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Thrown when attempting to add an invalid device name to the tree.
Definition: RoutingExceptions.h:46
Thrown when attempting to go to the parent path when forbidden.
Definition: RoutingExceptions.h:77
Thrown when attempting to go use an absolute path when forbidden.
Definition: RoutingExceptions.h:69
Thrown when attempting to use a path with no leading slash where an absolute path is required...
Definition: RoutingExceptions.h:91
Thrown when attempting to go to the parent path from the root.
Definition: RoutingExceptions.h:61
Thrown when attempting to use an empty path.
Definition: RoutingExceptions.h:84