GyotoError.h
Go to the documentation of this file.
/*
Copyright 2011, 2013 Thibaut Paumard
This file is part of Gyoto.
Gyoto is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gyoto is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GyotoError_H_
#define __GyotoError_H_
#include <string>
#include "GyotoDefs.h"
namespace Gyoto {
class Error;
}
class Gyoto::Error
{
private:
const std::string message;
const int errcode;
public:
Error( const std::string m );
// Copy constructor
Error( const Gyoto::Error &o);
void Report() const ;
int getErrcode() const ;
operator const char * () const;
std::string get_message() const ;
typedef void Handler_t (const Error);
static void setHandler( Gyoto::Error::Handler_t* phandler);
};
namespace Gyoto {
void throwError( std::string );
}
#define GYOTO_ERROR(msg) Gyoto::throwError(std::string(__FILE__ ":" GYOTO_STRINGIFY(__LINE__) " in ")+ __PRETTY_FUNCTION__ + ": " + msg)
#endif
GyotoDefs.h
Gyoto ubiquitous macros and typedefs.
Gyoto::Error
Class for thowing exceptions.
Definition GyotoError.h:101
Gyoto::Error::Handler_t
void Handler_t(const Error)
Error handler type.
Definition GyotoError.h:159
Gyoto::Error::Report
void Report() const
Print-out error message on standard error.
Gyoto::Error::message
const std::string message
Error message.
Definition GyotoError.h:104
Gyoto::Error::Error
Error(const std::string m)
Constructor with an error message.
Gyoto::Error::getErrcode
int getErrcode() const
Retrieve error code.
Gyoto::Error::setHandler
static void setHandler(Gyoto::Error::Handler_t *phandler)
Set application error handler.
Gyoto::Error::errcode
const int errcode
Error code.
Definition GyotoError.h:111
Gyoto::Error::get_message
std::string get_message() const
Retrieve error message for custom handling of the exception.
Gyoto
Namespace for the Gyoto library.
Definition GyotoAstrobj.h:44
Gyoto::throwError
void throwError(std::string)
Throw a Gyoto::Error.