|
DAS
3.0
Das Analysis System
|
Go to the documentation of this file. 1 #ifndef DARWIN_EXCEPTIONS_H
2 #define DARWIN_EXCEPTIONS_H
33 inline std::string
intercept_printf (std::function<
void()>
const lambda = []() { printf(__func__); })
35 char buffer[16384] = {0};
42 int saved_stdout = dup(STDOUT_FILENO);
44 if (pipe(out_pipe) != 0)
45 return "[`printf()` couldn't be intercepted]";
47 dup2(out_pipe[1], STDOUT_FILENO);
53 read(out_pipe[0], buffer,
sizeof(buffer)-1);
56 dup2(saved_stdout, STDOUT_FILENO);
63 struct AnomalousEvent :
public std::runtime_error {
67 template<
typename TTreePtr>
83 struct BadInput :
public std::invalid_argument {
88 std::function<
void()> helper
101 ) :
BadInput(error, [&userinfo](){ userinfo.
ls(); }) { }
106 const TObject&
object
107 ) :
BadInput(error, [&object](){
object.Print(); }) { }
112 const TDirectory& dir
113 ) :
BadInput(error, [&dir](){ dir.ls(); }) { }
118 BadInput (
const char * error,
const std::shared_ptr<T>& ptr
124 BadInput (
const char * error,
const std::unique_ptr<T>& ptr
131 inline void Diagnostic (
const boost::exception& e)
135 cerr <<
red << boost::diagnostic_information(e);
137 cerr <<
"To reproduce error, you may run:\n"
static const char * highlight
Definition: colours.h:9
cerr
Definition: Ntupliser_cfg.py:93
static const char * def
Definition: Step.h:36
void Diagnostic(const boost::exception &e)
Definition: exceptions.h:131
Handling of exceptions.
Definition: darwin.h:36
static const char * red
Definition: Step.h:34
AnomalousEvent(const char *error, const TTreePtr &tree)
Constructor for bad input tree.
Definition: exceptions.h:68
static const char * normal
Definition: colours.h:8
std::string intercept_printf(std::function< void()> const lambda=[]() { printf(__func__);})
Definition: exceptions.h:33
static const char * bold
Definition: Step.h:35