GyotoError.h File Reference

Error handling. More...

`#include <string>`
`#include "GyotoDefs.h"`

Go to the source code of this file.

## Classes

class | Gyoto::Error
| Class for thowing exceptions. More...

## Namespaces

namespace | Gyoto
| Namespace for the Gyoto library.

## Macros

#define | GYOTO_ERROR(msg)
| Throw a Gyoto::Error nicely.

## Functions

void | Gyoto::throwError (std::string)
| Throw a Gyoto::Error.

## Detailed Description

Error handling.

Gyoto dlopens its plug-ins. The throw/catch C++ mechanism cannot pass the dlopen boundary. The Gyoto::Error mechanism alleviates this C++ language limitation.

Every Gyoto method (either in the main Gyoto library or in a Gyoto plug-in) should check for possible error conditions and throw adequate Gyoto::Error exceptions through the Gyoto::Error::throw() function. For instance:

if (error_condition) Gyoto::Error::throw("Useful error message");

If the main code has set Gyoto::Error::handler_t error handler using Gyoto::Error::setHandler(), these errors will then be passed to it. Else, the Error is C++-thrown at the main Gyoto library level, above the dlopen boundary.

The main code can then catch these exceptions and act appropriately, for instance:

try { gyoto_code ; }
catch (Gyoto::Error err)
{
err.Report();
abort();
}
Gyoto::Error
Class for thowing exceptions.
Definition GyotoError.h:101
Gyoto::Error::Report
void Report() const
Print-out error message on standard error.

## Macro Definition Documentation

## GYOTO_ERROR

#define GYOTO_ERROR | ( |  | msg | ) |

Value:
Gyoto::throwError(std::string(__FILE__ ":" GYOTO_STRINGIFY(__LINE__) " in ")+ __PRETTY_FUNCTION__ + ": " + msg)
GYOTO_STRINGIFY
#define GYOTO_STRINGIFY(a)
Stringify macro content.
Definition GyotoDefs.h:568
Gyoto::throwError
void throwError(std::string)
Throw a Gyoto::Error.

Throw a Gyoto::Error nicely.

Throw an Error, prepending current function name. Calls Gyoto::throwError(std::string).