123#ifndef ATHENAKERNEL_ERRORCHECK_H
124#define ATHENAKERNEL_ERRORCHECK_H
127#include "GaudiKernel/StatusCode.h"
128#include "GaudiKernel/MsgStream.h"
129#include "GaudiKernel/IMessageSvc.h"
130#include "boost/preprocessor/facilities/overload.hpp"
134class INamedInterface;
148std::string
context_name (
const INamedInterface* context);
191 const std::string& context,
210 const std::string& context);
225 virtual MsgStream&
doOutput()
override;
311# define ERRORCHECK_FNAME __PRETTY_FUNCTION__
313# define ERRORCHECK_FNAME ""
317#ifndef ATLAS_PACKAGE_NAME
318# define ATLAS_PACKAGE_NAME nullptr
323#define ERRORCHECK_ARGS __LINE__, __FILE__, ERRORCHECK_FNAME, ATLAS_PACKAGE_NAME
333#define REPORT_ERROR_WITH_CONTEXT(SC, CONTEXT_NAME) \
334 errorcheck::ReportMessage (MSG::ERROR, ERRORCHECK_ARGS, CONTEXT_NAME, SC) \
345#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME) \
346 errorcheck::ReportMessage (LVL, ERRORCHECK_ARGS, CONTEXT_NAME).msgstream()
355#define REPORT_ERROR(SC) \
356 REPORT_ERROR_WITH_CONTEXT(SC, errorcheck::context_name (this))
365#define REPORT_MESSAGE(LVL) \
366 REPORT_MESSAGE_WITH_CONTEXT(LVL, errorcheck::context_name (this))
374#define CHECK_FAILED(EXP, CONTEXT_NAME, SC, RET) do { \
375 errorcheck::ReportMessage (MSG::ERROR, \
396#define CHECK_WITH_CONTEXT(...) \
397 BOOST_PP_OVERLOAD(CHECK_WITH_CONTEXT_, __VA_ARGS__)(__VA_ARGS__)
399#define CHECK_WITH_CONTEXT_2(EXP, CONTEXT_NAME) do { \
400 StatusCode sc__(EXP); \
401 if (! sc__.isSuccess()) \
402 CHECK_FAILED(EXP, CONTEXT_NAME, sc__, sc__); \
405#define CHECK_WITH_CONTEXT_3(EXP, CONTEXT_NAME, RET) do { \
406 StatusCode sc__(EXP); \
407 if (! sc__.isSuccess()) \
408 CHECK_FAILED(EXP, CONTEXT_NAME, sc__, RET); \
423 BOOST_PP_OVERLOAD(CHECK_, __VA_ARGS__)(__VA_ARGS__)
425#define CHECK_1(EXP) CHECK_WITH_CONTEXT(EXP, errorcheck::context_name(this))
426#define CHECK_2(EXP, RET) CHECK_WITH_CONTEXT(EXP, errorcheck::context_name(this), RET)
441#define CHECK_CODE_WITH_CONTEXT(EXP, CONTEXT_NAME, CODE) do { \
442 StatusCode sc__ = (EXP); \
443 if (! sc__.isSuccess()) { \
445 CHECK_FAILED(EXP, CONTEXT_NAME, sc__, sc__); \
460#define CHECK_CODE(EXP, CODE) \
461 CHECK_CODE_WITH_CONTEXT(EXP, errorcheck::context_name(this), CODE)
474#define CHECK_RECOVERABLE_WITH_CONTEXT(EXP, CONTEXT_NAME) \
475 CHECK_CODE_WITH_CONTEXT(EXP, CONTEXT_NAME, StatusCode::RECOVERABLE)
487#define CHECK_RECOVERABLE(EXP) \
488 CHECK_RECOVERABLE_WITH_CONTEXT(EXP, errorcheck::context_name(this))
501#define CHECK_FATAL_WITH_CONTEXT(EXP, CONTEXT_NAME) \
502 CHECK_CODE_WITH_CONTEXT(EXP, CONTEXT_NAME, StatusCode::FAILURE)
514#define CHECK_FATAL(EXP) \
515 CHECK_FATAL_WITH_CONTEXT(EXP, errorcheck::context_name(this))
std::string::size_type m_pos
The position in the output message after the standard header.
static std::atomic< bool > s_hide_function_names
If true, hide the function names in output messages.
MsgStream & msgstream()
Convert to a MsgStream reference.
virtual MsgStream & doOutput() override
Emit the message.
~ReportMessage()
Destructor.
static std::atomic< bool > s_hide_error_locus
If true, hide the source file and line number in output messages.
static void hideFunctionNames(bool flag=true)
If set to true, hide function names in the output.
static void hideErrorLocus(bool flag=true)
If set to true, hide the source file and line number in the output.
ReportMessage(MSG::Level level, int line, const char *file, const char *func, const char *pkg, const std::string &context, StatusCode sc)
Constructor.
void format_common(MSG::Level level, int line, const char *file, const char *func, const char *pkg)
Generate the common header for messages.
std::string context_name(const INamedInterface *context)
Return the context name from a context (this) pointer.