Loading...
Searching...
No Matches
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
32namespace 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
54 DUPLICATE_NAME,
55
57 RESERVED_NAME,
58
60 ATTRIBUTE_MISSING,
61
63 ATTRIBUTE_INVALID,
64
66 ATTRIBUTE_DEPRECATED,
67
69 ELEMENT_MISSING,
70
72 ELEMENT_INVALID,
73
75 ELEMENT_DEPRECATED,
76
80 ELEMENT_INCORRECT_TYPE,
81
83 URI_INVALID,
84
86 URI_LOOKUP,
87
89 DIRECTORY_NONEXISTANT,
90
92 MODEL_CANONICAL_LINK_INVALID,
93
95 MODEL_WITHOUT_LINK,
96
98 NESTED_MODELS_UNSUPPORTED,
99
101 LINK_INERTIA_INVALID,
102
104 JOINT_CHILD_LINK_INVALID,
105
107 JOINT_PARENT_LINK_INVALID,
108
110 JOINT_PARENT_SAME_AS_CHILD,
111
114 FRAME_ATTACHED_TO_INVALID,
115
117 FRAME_ATTACHED_TO_CYCLE,
118
120 FRAME_ATTACHED_TO_GRAPH_ERROR,
121
124 POSE_RELATIVE_TO_INVALID,
125
127 POSE_RELATIVE_TO_CYCLE,
128
130 POSE_RELATIVE_TO_GRAPH_ERROR,
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
187 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
Definition Error.hh:137
friend SDFORMAT_VISIBLE std::ostream & operator<<(std::ostream &_out, const sdf::Error &_err)
Output operator for an error.
ErrorCode Code() const
Get the error code.
std::string Message() const
Get the error message, which is a description of the error.
Error()=default
default constructor
Error(const ErrorCode _code, const std::string &_message)
Constructor.
bool operator==(const bool _value) const
Compare this Error to a boolean value.
@ NONE
An unspecified sensor type.
ErrorCode
Set of error codes.
Definition Error.hh:45
namespace for Simulation Description Format parser
Definition Actor.hh:33
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:48