Error.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef SDF_ERROR_HH_
18 #define SDF_ERROR_HH_
19 
20 #include <iostream>
21 #include <string>
22 #include <sdf/sdf_config.h>
23 #include "sdf/system_util.hh"
24 
25 #ifdef _WIN32
26 // Disable warning C4251 which is triggered by
27 // std::string
28 #pragma warning(push)
29 #pragma warning(disable: 4251)
30 #endif
31 
32 namespace sdf
33 {
34  // Inline bracket to help doxygen filtering.
35  inline namespace SDF_VERSION_NAMESPACE {
36  //
37 
44  enum class ErrorCode
45  {
46  // \brief No error
47  NONE = 0,
48 
50  FILE_READ,
51 
55 
58 
61 
64 
67 
70 
73 
76 
81 
84 
86  URI_LOOKUP,
87 
90 
93 
96 
99 
102 
105 
108 
111 
115 
118 
121 
125 
128 
131 
133  STRING_READ,
134  };
135 
137  {
139  public: Error() = default;
140 
145  public: Error(const ErrorCode _code, const std::string &_message);
146 
150  public: ErrorCode Code() const;
151 
154  public: std::string Message() const;
155 
159  public: explicit operator bool() const;
160 
168  public: bool operator==(const bool _value) const;
169 
174  public: friend SDFORMAT_VISIBLE std::ostream &operator<<(
175  std::ostream &_out, const sdf::Error &_err);
176 
178  private: ErrorCode code = ErrorCode::NONE;
179 
180 #ifdef _WIN32
181  // Disable warning C4251 which is triggered by
182  // std::string
183  #pragma warning(push)
184  #pragma warning(disable: 4251)
185 #endif
186  private: std::string message = "";
188 #ifdef _WIN32
189  #pragma warning(pop)
190 #endif
191  };
192  }
193 }
194 #ifdef _WIN32
195 #pragma warning(pop)
196 #endif
197 
198 
199 #endif
sdf::v9::ErrorCode::ELEMENT_INVALID
@ ELEMENT_INVALID
This error indicates that an SDF element is invalid.
sdf::v9::ErrorCode::FRAME_ATTACHED_TO_INVALID
@ FRAME_ATTACHED_TO_INVALID
The frame attached-to value does not match the name of an existing frame in the current scope.
sdf::v9::ErrorCode::DUPLICATE_NAME
@ DUPLICATE_NAME
A duplicate name was found for an element where unique names are required.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:32
sdf::v9::ErrorCode::ATTRIBUTE_DEPRECATED
@ ATTRIBUTE_DEPRECATED
This error indicates that an SDF attribute is deprecated.
sdf::v9::ErrorCode::NESTED_MODELS_UNSUPPORTED
@ NESTED_MODELS_UNSUPPORTED
Indicates that a DOM object tried to read a nested model.
sdf::v9::operator<<
std::ostream & operator<<(std::ostream &os, ParamStreamer< T > s)
Definition: Param.hh:75
sdf::v9::ErrorCode::MODEL_WITHOUT_LINK
@ MODEL_WITHOUT_LINK
A model without a link.
sdf::v9::ErrorCode::JOINT_PARENT_LINK_INVALID
@ JOINT_PARENT_LINK_INVALID
A joint has an invalid parent link.
sdf::v9::ErrorCode::POSE_RELATIVE_TO_GRAPH_ERROR
@ POSE_RELATIVE_TO_GRAPH_ERROR
The pose relative-to graph has an internal error.
sdf::v9::ErrorCode::POSE_RELATIVE_TO_INVALID
@ POSE_RELATIVE_TO_INVALID
The pose relative-to value does not match the name of an existing frame in the current scope.
sdf::v9::ErrorCode::RESERVED_NAME
@ RESERVED_NAME
A reserved name was used in an entity name attribute.
sdf::v9::ErrorCode::ATTRIBUTE_INVALID
@ ATTRIBUTE_INVALID
This error indicates that an SDF attribute is invalid.
sdf::v9::ErrorCode
ErrorCode
Definition: Error.hh:44
sdf::v9::ErrorCode::FRAME_ATTACHED_TO_CYCLE
@ FRAME_ATTACHED_TO_CYCLE
The frame attached-to graph contains a cycle.
sdf::v9::Error
Definition: Error.hh:136
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:48
sdf::v9::ErrorCode::LINK_INERTIA_INVALID
@ LINK_INERTIA_INVALID
A link has invalid inertia.
sdf::v9::ErrorCode::JOINT_PARENT_SAME_AS_CHILD
@ JOINT_PARENT_SAME_AS_CHILD
A joint has the same link specified as parent and child.
sdf::v9::ErrorCode::URI_LOOKUP
@ URI_LOOKUP
A error occured while trying to resolve a URI.
sdf::v9::ErrorCode::MODEL_CANONICAL_LINK_INVALID
@ MODEL_CANONICAL_LINK_INVALID
A model with an invalid canonical link.
sdf::v9::ErrorCode::DIRECTORY_NONEXISTANT
@ DIRECTORY_NONEXISTANT
A filesystem directory does not exist.
sdf::v9::ErrorCode::JOINT_CHILD_LINK_INVALID
@ JOINT_CHILD_LINK_INVALID
A joint has an invalid child link.
sdf::v9::ErrorCode::URI_INVALID
@ URI_INVALID
A URI is invalid.
sdf::v9::ErrorCode::POSE_RELATIVE_TO_CYCLE
@ POSE_RELATIVE_TO_CYCLE
The pose relative-to graph contains a cycle.
sdf::v9::ErrorCode::ATTRIBUTE_MISSING
@ ATTRIBUTE_MISSING
Indicates that a required SDF attribute is missing.
sdf::v9::ErrorCode::FILE_READ
@ FILE_READ
Indicates that reading an SDF file failed.
sdf::v9::ErrorCode::FRAME_ATTACHED_TO_GRAPH_ERROR
@ FRAME_ATTACHED_TO_GRAPH_ERROR
The frame attached-to graph has an internal error.
sdf::v9::ErrorCode::STRING_READ
@ STRING_READ
Indicates that reading an SDF string failed.
sdf::v9::ErrorCode::ELEMENT_INCORRECT_TYPE
@ ELEMENT_INCORRECT_TYPE
Indicates that an incorrect SDF element type was encountered.
system_util.hh
sdf::v9::ErrorCode::ELEMENT_MISSING
@ ELEMENT_MISSING
Indicates that a required SDF element is missing.
sdf::v9::ErrorCode::NONE
@ NONE
sdf::v9::ErrorCode::ELEMENT_DEPRECATED
@ ELEMENT_DEPRECATED
This error indicates that an SDF element is deprecated.