All Classes Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
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 <stdint.h>
24 #include <string>
25 
26 #include "sdf/system_util.hh"
27 
28 namespace sdf
29 {
32 
35  #define sdfthrow(msg) {std::ostringstream throwStream;\
36  throwStream << msg << std::endl << std::flush;\
37  throw sdf::Exception(__FILE__, __LINE__, throwStream.str()); }
38 
39  class ExceptionPrivate;
40 
44  {
46  public: Exception();
47 
52  public: Exception(const char *_file,
53  int64_t _line,
54  std::string _msg);
55 
57  public: virtual ~Exception();
58 
61  public: std::string GetErrorFile() const;
62 
65  public: std::string GetErrorStr() const;
66 
68  public: void Print() const;
69 
70 
74  public: friend std::ostream &operator<<(std::ostream& _out,
75  const sdf::Exception &_err)
76  {
77  return _out << _err.GetErrorStr();
78  }
79 
81  private: ExceptionPrivate *dataPtr;
82  };
83 
89  {
91  public: InternalError();
92 
97  public: InternalError(const char *_file, int64_t _line,
98  const std::string _msg);
99 
101  public: virtual ~InternalError();
102  };
103 
110  {
118  public: AssertionInternalError(const char *_file,
119  int64_t _line,
120  const std::string _expr,
121  const std::string _function,
122  const std::string _msg = "");
124  public: virtual ~AssertionInternalError();
125  };
127 }
128 
129 #endif
Definition: ExceptionPrivate.hh:28
friend std::ostream & operator<<(std::ostream &_out, const sdf::Exception &_err)
stream insertion operator for Gazebo Error
Definition: Exception.hh:74
Class for generating Internal Gazebo Errors: those errors which should never happend and represent pr...
Definition: Exception.hh:88
Class for generating exceptions.
Definition: Exception.hh:43
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
std::string GetErrorStr() const
Return the error string.
Class for generating Exceptions which come from sdf assertions.
Definition: Exception.hh:109