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 
58  public: Exception(const Exception &_e);
59 
61  public: virtual ~Exception();
62 
65  public: std::string GetErrorFile() const;
66 
69  public: std::string GetErrorStr() const;
70 
72  public: void Print() const;
73 
74 
78  public: friend std::ostream &operator<<(std::ostream& _out,
79  const sdf::Exception &_err)
80  {
81  return _out << _err.GetErrorStr();
82  }
83 
85  private: ExceptionPrivate *dataPtr;
86  };
87 
93  {
95  public: InternalError();
96 
101  public: InternalError(const char *_file, int64_t _line,
102  const std::string _msg);
103 
105  public: virtual ~InternalError();
106  };
107 
114  {
122  public: AssertionInternalError(const char *_file,
123  int64_t _line,
124  const std::string _expr,
125  const std::string _function,
126  const std::string _msg = "");
128  public: virtual ~AssertionInternalError();
129  };
131 }
132 
133 #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:78
Class for generating Internal Gazebo Errors: those errors which should never happend and represent pr...
Definition: Exception.hh:92
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:113