piranha  0.10
Classes | Namespaces | Macros
exceptions.hpp File Reference

Exceptions. More...

#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>
#include <piranha/type_traits.hpp>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  piranha::not_implemented_error
 Exception for functionality not implemented or not available on the current platform. More...
 
struct  piranha::zero_division_error
 Exception for signalling division by zero. More...
 

Namespaces

 piranha
 Root piranha namespace.
 

Macros

#define piranha_throw(exception_type, ...)   piranha::ex_thrower<exception_type>(__FILE__, __LINE__, __func__)(__VA_ARGS__)
 Exception-throwing macro. More...
 

Detailed Description

Exceptions.

This header contains custom exceptions used within piranha and related utilities.

Definition in file exceptions.hpp.

Macro Definition Documentation

◆ piranha_throw

#define piranha_throw (   exception_type,
  ... 
)    piranha::ex_thrower<exception_type>(__FILE__, __LINE__, __func__)(__VA_ARGS__)

Exception-throwing macro.

By default, this variadic macro will throw an exception of type exception_type, using the variadic arguments for the construction of the exception object. The macro will check if the exception can be constructed from the variadic arguments, and will produce a compilation error in case no suitable constructor is found.

Additionally, given a set of variadic arguments [arg0,arg1,...], and

  • if the first variadic argument arg0 can be concatenated to an std::string via the += operator,
  • and if the exception can be constructed from the set of arguments [str,arg1,...], where str is an instance of std::string,

then the first argument arg0 is interpreted as the error message associated to the exception object, and it will be decorated with information about the context in which the exception was thrown (file, line, function) before being passed on for construction.

Note that, in order to be fully standard-compliant, for use with exceptions that take no arguments on construction the invocation must include a closing comma. E.g.,

piranha_throw(std::bad_alloc);

is not correct, whereas

piranha_throw(std::bad_alloc,);

is correct.

Parameters
exception_typethe type of the exception to be thrown.

Definition at line 118 of file exceptions.hpp.