CGRA-ME
|
#include <cstdlib>
#include <exception>
#include <sstream>
#include <stdexcept>
#include <string>
Go to the source code of this file.
Classes | |
struct | cgrame_error |
struct | cgrame_mapper_error |
struct | cgrame_visual_error |
struct | cgrame_adl_error |
struct | cgrame_model_error |
Functions | |
template<typename EXCEPTION , typename FUNC > | |
void | make_and_throw (FUNC func) |
template<typename T , typename FUNC > | |
auto | make_from_stream (FUNC func) |
template<typename F > | |
std::string | string_from_stream (F &&f) |
void | tryToSafelyPrintExceptionInfo (std::exception_ptr eptr, std::ostream &os, const char *action_name) noexcept |
void | printExceptionToOutAndErr (std::exception_ptr eptr, const char *line_prefix, const char *message) |
void make_and_throw | ( | FUNC | func | ) |
A convenience function for throwing exceptions. Lets you do this:
int x = computation() if (x != 0) { make_and_throw([&](auto&& s) { s << "x was not zero! it was " << x; }); }
Definition at line 66 of file Exception.h.
auto make_from_stream | ( | FUNC | func | ) |
A convenience function for constructing things that expect strings, but when you would like to use a stream. Such as throwing exceptions. Lets you do this:
int x = computation() if (x != 0) { throw make_from_stream<std::logic_error>([&](auto&& s) { s << "x was not zero! it was " << x; }); }
Definition at line 85 of file Exception.h.
|
inline |
Prints a message to both stderr and stdout derived from eptr
Intended to be used when an exception is going to be ignored. Handles std::nested_exception properly, and will print messages from the nested exceptions.
Definition at line 134 of file Exception.h.
std::string string_from_stream | ( | F && | f | ) |
Runs the given functor on a stringstream, and retuns the string
Definition at line 95 of file Exception.h.
|
inlinenoexcept |
Print the given eptr
to os
, reasonably safely Intended for use in a destructor or something, when an throw exception cannot be tolerated. Does not handle std::nested_exception specially. Will not allocate, except if os
does
Definition at line 107 of file Exception.h.