Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
SimulatorError.cpp 1.13 KiB
// This file is part of the Acts project.
//
// Copyright (C) 2020 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include "ActsFatras/Kernel/detail/SimulatorError.hpp"

namespace ActsFatras {
namespace detail {
namespace {

// Define a custom error code category derived from std::error_category
class SimulatorErrorCategory final : public std::error_category {
 public:
  const char* name() const noexcept final { return "SimulatorError"; }
  std::string message(int c) const final {
    switch (static_cast<SimulatorError>(c)) {
      case SimulatorError::eInvalidInputParticleId:
        return "Input particle id with non-zero generation or sub-particle";
      default:
        return "unknown";
    }
  }
};

const SimulatorErrorCategory s_simulatorErrorCategory;

}  // namespace

std::error_code make_error_code(SimulatorError e) {
  return {static_cast<int>(e), s_simulatorErrorCategory};
}

}  // namespace detail
}  // namespace ActsFatras