DAS  3.0
Das Analysis System
Darwin::Exceptions Namespace Reference

Classes

struct  AnomalousEvent
 
struct  BadInput
 

Functions

std::string intercept_printf (std::function< void()> const lambda=[]() { printf(__func__);})
 
void Diagnostic (const boost::exception &e)
 

Variables

 git_error_category
 

Detailed Description

Handling of exceptions.

Function Documentation

◆ Diagnostic()

void Diagnostic ( const boost::exception &  e)
inline

Standard exception diagnostic, including the expanded command, software versions, and link to the documentation.

Parameters
eargument of `catch` block
117 {
118  using namespace std;
119  namespace DT = Darwin::Tools;
120  cerr << red << boost::diagnostic_information(e);
121  if (!DT::Options::full_cmd.empty())
122  cerr << "To reproduce error, you may run:\n"
123  << highlight << DT::Options::full_cmd << def << '\n';
124  cerr << def;
125 }

◆ intercept_printf()

std::string intercept_printf ( std::function< void()> const  lambda = []() { printf(__func__); })
inline

Solution found on Stackoverflow to intercept the output of printf (which is still used by ROOT in several places, e.g. TTree::Show()).

https://stackoverflow.com/questions/5911147/how-to-redirect-printf-output-back-into-code

25  { printf(__func__); })
26 {
27  char buffer[16384] = {0};
28  int out_pipe[2];
29  int saved_stdout = dup(STDOUT_FILENO); /* save stdout for display later */
30 
31  if (pipe(out_pipe) != 0) // make a pipe
32  return "[`printf()` couldn't be intercepted]";
33 
34  dup2(out_pipe[1], STDOUT_FILENO); /* redirect stdout to the pipe */
35  close(out_pipe[1]);
36 
37  lambda();
38  fflush(stdout);
39 
40  read(out_pipe[0], buffer, sizeof(buffer)-1); /* read from pipe into buffer */
41  dup2(saved_stdout, STDOUT_FILENO); /* reconnect stdout for testing */
42 
43  return buffer;
44 }

Variable Documentation

◆ git_error_category

git_error_category

Error category for libgit2.

highlight
static const char * highlight
Definition: colours.h:9
Ntupliser_cfg.cerr
cerr
Definition: Ntupliser_cfg.py:93
Step::def
static const char * def
Definition: Step.h:36
Step::red
static const char * red
Definition: Step.h:34
Darwin::Tools
Classes and functions related to the framework.
Definition: forceMetaInfo.cc:28
Darwin::Tools::Options::full_cmd
static std::string full_cmd
extended version of the command for reproducibility
Definition: Options.h:266