ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimulatorError.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SimulatorError.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
11 namespace ActsFatras {
12 namespace detail {
13 namespace {
14 
15 // Define a custom error code category derived from std::error_category
16 class SimulatorErrorCategory final : public std::error_category {
17  public:
18  const char* name() const noexcept final { return "SimulatorError"; }
19  std::string message(int c) const final {
20  switch (static_cast<SimulatorError>(c)) {
21  case SimulatorError::eInvalidInputParticleId:
22  return "Input particle id with non-zero generation or sub-particle";
23  default:
24  return "unknown";
25  }
26  }
27 };
28 
29 const SimulatorErrorCategory s_simulatorErrorCategory;
30 
31 } // namespace
32 
33 std::error_code make_error_code(SimulatorError e) {
34  return {static_cast<int>(e), s_simulatorErrorCategory};
35 }
36 
37 } // namespace detail
38 } // namespace ActsFatras