ATLAS Offline Software
error.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
14 #ifdef __GXX_ABI_VERSION
15 # include <cstdlib>
16 # include <cxxabi.h>
17 #endif
18 #include <iomanip>
19 #include <iostream>
20 #include <sstream>
21 
22 
23 #ifdef XAOD_STANDALONE
24 
25 
26 namespace AthContainers_detail {
27 
28 
30 void reportErrorStandalone (const std::string& context,
31  const std::string& file, int line,
32  const std::string& msg) {
33 
34  // Make sure that the message's source/location is not longer than a
35  // pre-set maximum value.
36  std::string source (context);
37  static constexpr std::size_t CONTEXT_WIDTH = 18;
38  if (source.size() > CONTEXT_WIDTH) {
39  source = source.substr(0, CONTEXT_WIDTH - 3);
40  source += "...";
41  }
42 
43  // Print the message to stdout/std::cout.
44  std::ostringstream output;
45  output << std::setiosflags(std::ios::left)
46  << std::setw(CONTEXT_WIDTH) << source << " ERROR "
47  << file << ":" << line << ": "
48  << msg;
49  std::cout << output.str() << std::endl;
50  return;
51 }
52 
53 
63 std::string typeinfoName (const std::type_info& ti)
64 {
65  // In case the "translation" is not successful, the fallback is to
66  // keep the original, mangled name:
67  std::string result = ti.name();
68 
69 #ifdef __GXX_ABI_VERSION
70  // Try to demangle the name:
71  int status;
72  char* typeName = abi::__cxa_demangle( ti.name(), 0, 0, &status );
73  if (status == 0) {
74  // Take the demangled name, and free up the memory allocated in
75  // the process:
76  result = typeName;
77  ::free( typeName );
78  }
79 #endif
80 
81  return result;
82 }
83 
84 
85 } // namespace AthContainers_detail
86 
87 
88 #endif // XAOD_STANDALONE
checkFileSG.line
line
Definition: checkFileSG.py:75
get_generator_info.result
result
Definition: get_generator_info.py:21
AthContainers_detail
Definition: error.h:53
file
TFile * file
Definition: tile_monitor.h:29
error.h
Helper for emitting error messages.
merge.output
output
Definition: merge.py:17
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
merge.status
status
Definition: merge.py:17
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7