The Gaudi Framework  v30r3 (a5ef0a68)
ErrorTool.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_ERRORTOOL_H
2 #define GAUDIALG_ERRORTOOL_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // Gaudi
7 // ============================================================================
8 #include "GaudiAlg/GaudiTool.h"
9 #include "GaudiAlg/IErrorTool.h"
10 // ============================================================================
11 
12 // ============================================================================
19 // ============================================================================
20 
21 class ErrorTool : public GaudiTool, virtual public IErrorTool
22 {
23 
24 public:
32  ErrorTool( const std::string& type, const std::string& name, const IInterface* parent );
33 
34 public:
57  const size_t mx = 10 ) const override
58  {
59  return GaudiTool::Error( msg, st, mx );
60  }
61 
73  const size_t mx = 10 ) const override
74  {
75  return GaudiTool::Warning( msg, st, mx );
76  }
77 
88  const MSG::Level lev = MSG::INFO ) const override
89  {
90  return GaudiTool::Print( msg, st, lev );
91  }
92 
102  void Assert( const bool ok, const std::string& message = "",
103  const StatusCode sc = StatusCode::FAILURE ) const override
104  {
105  GaudiTool::Assert( ok, message, sc );
106  }
107 
116  void Exception( const std::string& msg, const GaudiException& exc,
117  const StatusCode sc = StatusCode::FAILURE ) const override
118  {
119  GaudiTool::Exception( msg, exc, sc );
120  }
121 
130  void Exception( const std::string& msg, const std::exception& exc,
131  const StatusCode sc = StatusCode::FAILURE ) const override
132  {
133  GaudiTool::Exception( msg, exc, sc );
134  }
135 
143  void Exception( const std::string& msg = "no message", const StatusCode sc = StatusCode::FAILURE ) const override
144  {
145  GaudiTool::Exception( msg, sc );
146  }
147 };
148 
149 #endif // GAUDIALG_ERRORTOOL_H
constexpr static const auto FAILURE
Definition: StatusCode.h:88
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
StatusCode Warning(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the warning message and return with the given StatusCode.
Definition: GaudiTool.h:710
Header file for class GaudiAlgorithm.
Define general base for Gaudi exception.
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode::FAILURE) const override
Create and (re)-throw the exception.
Definition: ErrorTool.h:116
virtual const std::string & type() const =0
The type of an AlgTool, meaning the concrete AlgTool class.
void Assert(const bool ok, const std::string &message="", const StatusCode sc=StatusCode::FAILURE) const override
Assertion - throw exception, if condition is not fulfilled.
Definition: ErrorTool.h:102
STL class.
StatusCode Print(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const override
Print the message and return status code.
Definition: ErrorTool.h:87
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
Definition of the basic interface.
Definition: IInterface.h:277
WARN_UNUSED StatusCode Print(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
Print the message and return with the given StatusCode.
StatusCode Warning(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const override
Print the warning message, return status code and perform the statistics of warning messages...
Definition: ErrorTool.h:72
STL class.
ErrorTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: ErrorTool.cpp:32
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:62
StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the error message and return with the given StatusCode.
Definition: GaudiTool.h:682
StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const override
Print the error message, return status code and perform the statistics of error messages.
Definition: ErrorTool.h:56
void Assert(const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Assertion - throw exception if the given condition is not fulfilled.
The useful base class for tools.
Definition: GaudiTool.h:101
void Exception(const std::string &msg="no message", const StatusCode sc=StatusCode::FAILURE) const override
Create and throw the exception.
Definition: ErrorTool.h:143
void Exception(const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode::FAILURE) const override
Create and (re)-throw the exception.
Definition: ErrorTool.h:130
virtual const IInterface * parent() const =0
The parent of the concrete AlgTool.
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.