Camargue
Classes | Namespaces | Macros | Functions
err_util.hpp File Reference

ERROR HANDLING CLASSES AND ROUTINES. More...

#include <stdexcept>
#include <string>
#include <iostream>
Include dependency graph for err_util.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CMR::util::ScopeGuard< act_type >
 Code from Andrei Alexandrescu's ScopeGuard11 slides. More...
 
struct  CMR::util::retcode_error
 Structure for converting retcodes to exceptions. More...
 

Namespaces

 CMR
 The namespace for this project.
 
 CMR::util
 Utility functions/structures used miscellaneous places in the project.
 

Macros

#define CMR_CATCH_PRINT_THROW(msg, new_ex)
 Macro for handling errors in function with multiple failure points. More...
 

Functions

template<typename act_type >
ScopeGuard< act_type > CMR::util::make_guard (act_type f)
 Type deduction function for ScopeGuard, also from Andrei Alexandrescu. More...
 

Detailed Description

ERROR HANDLING CLASSES AND ROUTINES.

This file contains classes for creating cleanup objects and exceptions derived from standard library runtime error.


Macro Definition Documentation

#define CMR_CATCH_PRINT_THROW (   msg,
  new_ex 
)
Value:
catch(const std::exception &e) \
{ std::cerr << e.what() << " " << msg << ".\n"; throw new_ex; }

Macro for handling errors in function with multiple failure points.

Suggested usage: This macro should be used in a function by initially declaring a runtime_error new_ex("Function failed."). Then, for various smaller tasks within the function that may throw for distinct reasons (and which throw exceptions derived from std::exception), use a try block followed by CMR_CATCH_PRINT_THROW("description of failure in small task", new_ex).