ewmscp  ..
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
errorReport Class Reference

class for easy error handling with davix ensures proper cleanup of the error report when going out of scope allows easy throwing of std::runtime_error exceptions More...

#include <davixCommon.h>

Collaboration diagram for errorReport:
[legend]

Public Member Functions

 errorReport (const std::string &aFunc, const std::string &aWhat, const std::string &aPath)
 
 operator Davix::DavixError ** ()
 
Davix::DavixError * operator-> ()
 
const std::string & getMessage () const
 
void throwUp ()
 
 ~errorReport ()
 

Private Attributes

Davix::DavixError * report
 
copyRequest::clock_type::time_point start
 
const std::string func
 
const std::string what
 
const std::string & path
 

Static Private Attributes

static options::single< bool > withTiming
 

Detailed Description

class for easy error handling with davix ensures proper cleanup of the error report when going out of scope allows easy throwing of std::runtime_error exceptions

Definition at line 12 of file davixCommon.h.

Constructor & Destructor Documentation

◆ errorReport()

errorReport::errorReport ( const std::string &  aFunc,
const std::string &  aWhat,
const std::string &  aPath 
)
inline

Definition at line 20 of file davixCommon.h.

22  : report(nullptr),
23  start(std::chrono::system_clock::now()),
24  func(aFunc),
25  what(aWhat),
26  path(aPath) {
27  };

◆ ~errorReport()

errorReport::~errorReport ( )
inline

Definition at line 56 of file davixCommon.h.

56  {
57  Davix::DavixError::clearError(&report);
58  if (withTiming) {
59  auto now = copyRequest::clock_type::now();
60  auto dt = std::chrono::duration_cast<std::chrono::duration<double>>(now - start).count();
61  std::cerr << func << ":" << what << ": " << std::fixed << dt << "\n";
62  }
63  }

References func, report, start, what, and withTiming.

Member Function Documentation

◆ getMessage()

const std::string& errorReport::getMessage ( ) const
inline

Definition at line 37 of file davixCommon.h.

37  {
38  if (report == nullptr) {
39  static const std::string noMessageYet("no davix eror set");
40  return noMessageYet;
41  } else {
42  return report->getErrMsg();
43  }
44  }

References report.

Referenced by outputHandler::davix::writerDavix::closeAndRemoveBadCopy(), inputHandler::davix::DavixDirectory::~DavixDirectory(), and inputHandler::davix::readerDavix::~readerDavix().

Here is the caller graph for this function:

◆ operator Davix::DavixError **()

errorReport::operator Davix::DavixError ** ( )
inline

Definition at line 28 of file davixCommon.h.

28  {
29  return &report;
30  }

References report.

◆ operator->()

Davix::DavixError* errorReport::operator-> ( )
inline

Definition at line 31 of file davixCommon.h.

31  {
32  if (report == nullptr) {
33  throw std::runtime_error("no davix error set");
34  }
35  return report;
36  }

References report.

◆ throwUp()

void errorReport::throwUp ( )
inline

Member Data Documentation

◆ func

const std::string errorReport::func
private

Definition at line 16 of file davixCommon.h.

Referenced by throwUp(), and ~errorReport().

◆ path

const std::string& errorReport::path
private

Definition at line 18 of file davixCommon.h.

Referenced by throwUp().

◆ report

Davix::DavixError* errorReport::report
private

◆ start

copyRequest::clock_type::time_point errorReport::start
private

Definition at line 15 of file davixCommon.h.

Referenced by ~errorReport().

◆ what

const std::string errorReport::what
private

Definition at line 17 of file davixCommon.h.

Referenced by throwUp(), and ~errorReport().

◆ withTiming

options::single<bool> errorReport::withTiming
staticprivate

Definition at line 13 of file davixCommon.h.

Referenced by ~errorReport().


The documentation for this class was generated from the following file:
errorReport::start
copyRequest::clock_type::time_point start
Definition: davixCommon.h:15
errorReport::withTiming
static options::single< bool > withTiming
Definition: davixCommon.h:13
errorReport::what
const std::string what
Definition: davixCommon.h:17
errorReport::path
const std::string & path
Definition: davixCommon.h:18
errorReport::report
Davix::DavixError * report
Definition: davixCommon.h:14
errorReport::func
const std::string func
Definition: davixCommon.h:16