The Gaudi Framework  master (37c0b60a)
StatusCode.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 #define GAUDIKERNEL_STATUSCODE_CPP 1
12 
13 #include <GaudiKernel/Bootstrap.h>
17 #include <GaudiKernel/MsgStream.h>
18 #include <GaudiKernel/StatusCode.h>
19 #include <GaudiKernel/System.h>
20 #include <exception>
21 
25 
26 namespace {
28  struct DefaultCategory : public StatusCode::Category {
29 
30  const char* name() const override { return "Gaudi"; }
31 
32  std::string message( StatusCode::code_t code ) const override {
33  switch ( static_cast<StatusCode::ErrorCode>( code ) ) {
35  return "SUCCESS";
37  return "FAILURE";
39  return "RECOVERABLE";
40  default:
41  return "UNKNOWN(" + std::to_string( code ) + ")";
42  }
43  }
44  };
45 } // namespace
46 
48 
49 void StatusCode::i_doThrow( std::string_view message, std::string_view tag ) const {
50  throw GaudiException{ std::string{ message }, std::string{ tag }, *this };
51 }
StatusCode::ErrorCode::SUCCESS
@ SUCCESS
precedence.message
message
Definition: precedence.py:19
std::string
STL class.
System.h
GaudiException.h
GaudiException
Definition: GaudiException.h:31
StatusCode::code_t
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:67
StatusCode.h
IMessageSvc.h
StatusCode
Definition: StatusCode.h:65
StatusCode::Category
Definition: StatusCode.h:78
std::to_string
T to_string(T... args)
StatusCode::ErrorCode
ErrorCode
Definition: StatusCode.h:69
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
StatusCode::ErrorCode::RECOVERABLE
@ RECOVERABLE
STATUSCODE_ENUM_IMPL
#define STATUSCODE_ENUM_IMPL(...)
Assign a category to the StatusCode enum declared with STATUSCODE_ENUM_DECL( ENUM )
Definition: StatusCode.h:295
std
STL namespace.
StatusCode::ErrorCode::FAILURE
@ FAILURE
Bootstrap.h
StatusCode::Category::name
virtual const char * name() const =0
Name of the category.
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
ISvcLocator.h
StatusCode::RECOVERABLE
constexpr static const auto RECOVERABLE
Definition: StatusCode.h:102
MsgStream.h
StatusCode::Category::message
virtual std::string message(code_t code) const
Description for code within this category.
Definition: StatusCode.h:86