The Gaudi Framework  v33r1 (b1225454)
ErrorTool.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIALG_ERRORTOOL_H
12 #define GAUDIALG_ERRORTOOL_H 1
13 // ============================================================================
14 // Include files
15 // ============================================================================
16 // Gaudi
17 // ============================================================================
18 #include "GaudiAlg/GaudiTool.h"
19 #include "GaudiAlg/IErrorTool.h"
20 // ============================================================================
21 
22 // ============================================================================
29 // ============================================================================
30 
31 class ErrorTool : public GaudiTool, virtual public IErrorTool {
32 
33 public:
41  ErrorTool( const std::string& type, const std::string& name, const IInterface* parent );
42 
43 public:
66  const size_t mx = 10 ) const override {
67  return GaudiTool::Error( msg, st, mx );
68  }
69 
81  const size_t mx = 10 ) const override {
82  return GaudiTool::Warning( msg, st, mx );
83  }
84 
95  const MSG::Level lev = MSG::INFO ) const override {
96  return GaudiTool::Print( msg, st, lev );
97  }
98 
108  void Assert( const bool ok, const std::string& message = "",
109  const StatusCode sc = StatusCode::FAILURE ) const override {
110  GaudiTool::Assert( ok, message, sc );
111  }
112 
121  void Exception( const std::string& msg, const GaudiException& exc,
122  const StatusCode sc = StatusCode::FAILURE ) const override {
123  GaudiTool::Exception( msg, exc, sc );
124  }
125 
134  void Exception( const std::string& msg, const std::exception& exc,
135  const StatusCode sc = StatusCode::FAILURE ) const override {
136  GaudiTool::Exception( msg, exc, sc );
137  }
138 
146  void Exception( const std::string& msg = "no message", const StatusCode sc = StatusCode::FAILURE ) const override {
147  GaudiTool::Exception( msg, sc );
148  }
149 };
150 
151 #endif // GAUDIALG_ERRORTOOL_H
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:94
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:673
Header file for class GaudiAlgorithm.
Define general base for Gaudi exception.
void Assert(const bool ok, std::string_view message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Assertion - throw exception if the given condition is not fulfilled.
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
StatusCode Print(std::string_view msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
Print the message and return with the given StatusCode.
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:121
virtual const std::string & name() const =0
Retrieve the name of the instance.
STL class.
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:699
void Exception(std::string_view msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
Definition of the basic interface.
Definition: IInterface.h:254
virtual const std::string & type() const =0
The type of an AlgTool, meaning the concrete AlgTool class.
STL class.
ErrorTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: ErrorTool.cpp:42
virtual const IInterface * parent() const =0
The parent of the concrete AlgTool.
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:108
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:134
constexpr static const auto FAILURE
Definition: StatusCode.h:101
The useful base class for tools.
Definition: GaudiTool.h:111
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:65
void Exception(const std::string &msg="no message", const StatusCode sc=StatusCode::FAILURE) const override
Create and throw the exception.
Definition: ErrorTool.h:146
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:80