Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimulationError.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SimulationError.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020-2021 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 #include <string>
12 
13 namespace ActsFatras {
14 namespace detail {
15 namespace {
16 
17 // Define a custom error code category derived from std::error_category
18 class SimulationErrorCategory final : public std::error_category {
19  public:
20  const char* name() const noexcept final { return "SimulationError"; }
21  std::string message(int c) const final {
22  switch (static_cast<SimulationError>(c)) {
23  case SimulationError::eInvalidInputParticleId:
24  return "Input particle id with non-zero generation or sub-particle";
25  default:
26  return "unknown";
27  }
28  }
29 };
30 
31 const SimulationErrorCategory s_simulatorErrorCategory;
32 
33 } // namespace
34 
35 std::error_code make_error_code(SimulationError e) {
36  return {static_cast<int>(e), s_simulatorErrorCategory};
37 }
38 
39 } // namespace detail
40 } // namespace ActsFatras