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 <optional>
23 #include <ignition/utils/ImplPtr.hh>
24 #include <sdf/sdf_config.h>
25 #include "sdf/system_util.hh"
26 
27 #ifdef _WIN32
28 // Disable warning C4251 which is triggered by
29 // std::string
30 #pragma warning(push)
31 #pragma warning(disable: 4251)
32 #endif
33 
34 namespace sdf
35 {
36  // Inline bracket to help doxygen filtering.
37  inline namespace SDF_VERSION_NAMESPACE {
38  //
39 
46  enum class ErrorCode
47  {
48  // \brief No error
49  NONE = 0,
50 
52  FILE_READ,
53 
57 
60 
63 
66 
69 
73 
76 
79 
82 
87 
90 
92  URI_LOOKUP,
93 
96 
99 
102 
105 
108 
111 
114 
117 
121 
124 
127 
131 
134 
137 
139  STRING_READ,
140 
143 
146  };
147 
149  {
151  public: Error();
152 
157  public: Error(const ErrorCode _code, const std::string &_message);
158 
164  public: Error(const ErrorCode _code, const std::string &_message,
165  const std::string &_filePath);
166 
174  public: Error(const ErrorCode _code, const std::string &_message,
175  const std::string &_filePath, int _lineNumber);
176 
180  public: ErrorCode Code() const;
181 
184  public: std::string Message() const;
185 
189  public: std::optional<std::string> FilePath() const;
190 
193  public: std::optional<int> LineNumber() const;
194 
198  public: std::optional<std::string> XmlPath() const;
199 
204  public: void SetXmlPath(const std::string &_xmlPath);
205 
209  public: explicit operator bool() const;
210 
218  public: bool operator==(const bool _value) const;
219 
224  public: friend SDFORMAT_VISIBLE std::ostream &operator<<(
225  std::ostream &_out, const sdf::Error &_err);
226 
228  IGN_UTILS_IMPL_PTR(dataPtr)
229  };
230  }
231 }
232 #ifdef _WIN32
233 #pragma warning(pop)
234 #endif
235 
236 
237 #endif
A error occured while trying to resolve a URI.
A link has invalid inertia.
A duplicate name was found for an element where unique names are required.
A joint has an invalid child link.
std::ostream & operator<<(std::ostream &os, ParamStreamer< T > s)
Definition: Param.hh:78
This error indicates that an SDF attribute is invalid.
The pose relative-to graph contains a cycle.
The frame attached-to graph contains a cycle.
A filesystem directory does not exist.
This error indicates that an SDF element is invalid.
Indicates that a DOM object tried to read a nested model.
ErrorCode
Set of error codes.
Definition: Error.hh:46
Indicates that reading an SDF file failed.
Indicates an attribute was included that is not part of the sdf spec.
The specified placement frame is invalid.
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:41
The pose relative-to value does not match the name of an existing frame in the current scope...
The frame attached-to value does not match the name of an existing frame in the current scope...
The provided version has been deprecated or it is pre-versioning.
Indicates that an incorrect SDF element type was encountered.
A reserved name was used in an entity name attribute.
Indicates that a required SDF attribute is missing.
Indicates that reading an SDF string failed.
The pose relative-to graph has an internal error.
A joint has the same link specified as parent and child.
This error indicates that an SDF element is deprecated.
This error indicates that an SDF attribute is deprecated.
namespace for Simulation Description Format parser
Definition: Actor.hh:33
A model with an invalid canonical link.
The frame attached-to graph has an internal error.
Indicates that a required SDF element is missing.
Definition: Error.hh:148
A joint has an invalid parent link.