All Classes Namespaces Files Functions Variables Typedefs Friends Macros Modules
Exception.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 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 
18 #ifndef _SDF_EXCEPTION_HH_
19 #define _SDF_EXCEPTION_HH_
20 
21 #include <iostream>
22 #include <sstream>
23 #include <string>
24 
25 #include "sdf/system_util.hh"
26 
27 namespace sdf
28 {
31 
34  #define sdfthrow(msg) {std::ostringstream throwStream;\
35  throwStream << msg << std::endl << std::flush;\
36  throw sdf::Exception(__FILE__, __LINE__, throwStream.str()); }
37 
41  {
43  public: Exception();
44 
49  public: Exception(const char *_file,
50  int _line,
51  std::string _msg);
52 
54  public: virtual ~Exception();
55 
58  public: std::string GetErrorFile() const;
59 
62  public: std::string GetErrorStr() const;
63 
65  public: void Print() const;
66 
68  private: std::string file;
69 
71  private: int line;
72 
74  private: std::string str;
75 
79  public: friend std::ostream &operator<<(std::ostream& _out,
80  const sdf::Exception &_err)
81  {
82  return _out << _err.GetErrorStr();
83  }
84  };
85 
91  {
93  public: InternalError();
94 
99  public: InternalError(const char *_file, int _line,
100  const std::string _msg);
101 
103  public: virtual ~InternalError();
104  };
105 
112  {
120  public: AssertionInternalError(const char *_file,
121  int _line,
122  const std::string _expr,
123  const std::string _function,
124  const std::string _msg = "");
126  public: virtual ~AssertionInternalError();
127  };
129 }
130 
131 #endif
friend std::ostream & operator<<(std::ostream &_out, const sdf::Exception &_err)
stream insertion operator for Gazebo Error
Definition: Exception.hh:79
Class for generating Internal Gazebo Errors: those errors which should never happend and represent pr...
Definition: Exception.hh:90
Class for generating exceptions.
Definition: Exception.hh:40
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
std::string GetErrorStr() const
Return the error string.
namespace for Simulation Description Format parser
Definition: Console.hh:29
Class for generating Exceptions which come from sdf assertions.
Definition: Exception.hh:111