Gyoto
GyotoError.h
Go to the documentation of this file.
1 
34 /*
35  Copyright 2011, 2013 Thibaut Paumard
36 
37  This file is part of Gyoto.
38 
39  Gyoto is free software: you can redistribute it and/or modify
40  it under the terms of the GNU General Public License as published by
41  the Free Software Foundation, either version 3 of the License, or
42  (at your option) any later version.
43 
44  Gyoto is distributed in the hope that it will be useful,
45  but WITHOUT ANY WARRANTY; without even the implied warranty of
46  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47  GNU General Public License for more details.
48 
49  You should have received a copy of the GNU General Public License
50  along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
51  */
52 
53 #ifndef __GyotoError_H_
54 #define __GyotoError_H_
55 
61 #include <string>
62 #include "GyotoDefs.h"
63 
64 namespace Gyoto {
65  class Error;
66 }
67 
101 {
102  private:
104  const std::string message;
105  const std::string stacktrace;
106  std::string fullmessage;
107 
109 
113  const int errcode;
114 
115  public:
116 
118  Error( const std::string m );
119 
120  // Copy constructor
121  Error( const Gyoto::Error &o);
122 
124  void Report() const ;
125 
127 
131  int getErrcode() const ;
132 
134 
138  operator const char * () const;
139 
141 
147  std::string get_message() const ;
148 
150 
156  std::string get_stacktrace() const ;
157 
159 
172  typedef void Handler_t (const Error);
173 
175 
191  static void setHandler( Gyoto::Error::Handler_t* phandler);
192 
193 };
194 
195 namespace Gyoto {
197 
200  void throwError( std::string );
201 }
202 
203 
205 
209 #define GYOTO_ERROR(msg) Gyoto::throwError(std::string(__FILE__ ":" GYOTO_STRINGIFY(__LINE__) " in ")+ __PRETTY_FUNCTION__ + ": " + msg)
210 
211 #endif
static void setHandler(Gyoto::Error::Handler_t *phandler)
Set application error handler.
const std::string message
Error message.
Definition: GyotoError.h:104
Class for thowing exceptions.
Definition: GyotoError.h:100
std::string get_message() const
Retrieve error message for custom handling of the exception.
Error(const std::string m)
Constructor with an error message.
std::string get_stacktrace() const
Retrieve stacktrace description for custom handling of the exception.
const int errcode
Error code.
Definition: GyotoError.h:113
Gyoto ubiquitous macros and typedefs.
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:46
void throwError(std::string)
Throw a Gyoto::Error.
void Handler_t(const Error)
Error handler type.
Definition: GyotoError.h:172
int getErrcode() const
Retrieve error code.
void Report() const
Print-out error message on standard error.