|
DAS
3.0
Das Analysis System
|
Go to the documentation of this file. 1 #ifndef DARWIN_EXCEPTIONS_H
2 #define DARWIN_EXCEPTIONS_H
25 inline std::string
intercept_printf (std::function<
void()>
const lambda = []() { printf(__func__); })
27 char buffer[16384] = {0};
29 int saved_stdout = dup(STDOUT_FILENO);
31 if (pipe(out_pipe) != 0)
32 return "[`printf()` couldn't be intercepted]";
34 dup2(out_pipe[1], STDOUT_FILENO);
40 read(out_pipe[0], buffer,
sizeof(buffer)-1);
41 dup2(saved_stdout, STDOUT_FILENO);
52 template<
typename TTreePtr>
68 struct BadInput :
public std::invalid_argument {
73 std::function<
void()> helper
86 ) :
BadInput(error, [&userinfo](){ userinfo.
ls(); }) { }
92 ) :
BadInput(error, [&object](){
object.Print(
"all"); }) { }
98 ) :
BadInput(error, [&dir](){ dir.ls(); }) { }
103 BadInput (
const char * error,
const std::shared_ptr<T>& ptr
109 BadInput (
const char * error,
const std::unique_ptr<T>& ptr
120 cerr <<
red << boost::diagnostic_information(e);
122 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:116
Handling of exceptions.
Definition: darwin.h:34
static const char * red
Definition: Step.h:34
AnomalousEvent(const char *error, const TTreePtr &tree)
Constructor for bad input tree.
Definition: exceptions.h:53
static const char * normal
Definition: colours.h:8
std::string intercept_printf(std::function< void()> const lambda=[]() { printf(__func__);})
Definition: exceptions.h:25
Generic exception for problematic event (during event loop).
Definition: exceptions.h:48
static const char * bold
Definition: Step.h:35