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
64namespace Gyoto {
65 class Error;
66}
67
101{
102 private:
104 const std::string message;
105
107
111 const int errcode;
112
113 public:
114
116 Error( const std::string m );
117
118 // Copy constructor
119 Error( const Gyoto::Error &o);
120
122 void Report() const ;
123
125
129 int getErrcode() const ;
130
132
136 operator const char * () const;
137
139
143 std::string get_message() const ;
144
146
159 typedef void Handler_t (const Error);
160
162
178 static void setHandler( Gyoto::Error::Handler_t* phandler);
179
180};
181
182namespace Gyoto {
184
187 void throwError( std::string );
188}
189
190
192
196#define GYOTO_ERROR(msg) Gyoto::throwError(std::string(__FILE__ ":" GYOTO_STRINGIFY(__LINE__) " in ")+ __PRETTY_FUNCTION__ + ": " + msg)
197
198#endif
Gyoto ubiquitous macros and typedefs.
Class for thowing exceptions.
Definition: GyotoError.h:101
void Handler_t(const Error)
Error handler type.
Definition: GyotoError.h:159
void Report() const
Print-out error message on standard error.
const std::string message
Error message.
Definition: GyotoError.h:104
Error(const std::string m)
Constructor with an error message.
int getErrcode() const
Retrieve error code.
static void setHandler(Gyoto::Error::Handler_t *phandler)
Set application error handler.
const int errcode
Error code.
Definition: GyotoError.h:111
std::string get_message() const
Retrieve error message for custom handling of the exception.
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
void throwError(std::string)
Throw a Gyoto::Error.