EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VertexingError.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VertexingError.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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 
9 #pragma once
10 
11 #include <iostream>
12 #include <string> // for string printing
13 #include <system_error> // bring in std::error_code et al
14 
15 namespace Acts {
16 // This is the custom error code enum
17 enum class VertexingError {
18  NumericFailure = 1,
19  EmptyInput,
20  SeedingError,
21  NotConverged,
22  ElementNotFound,
23  NoCovariance
24 };
25 
26 namespace detail {
27 // Define a custom error code category derived from std::error_category
28 class VertexingErrorCategory : public std::error_category {
29  public:
30  // Return a short descriptive name for the category
31  const char* name() const noexcept final { return "VertexingError"; }
32  // Return what each enum means in text
33  std::string message(int c) const final {
34  switch (static_cast<VertexingError>(c)) {
35  case VertexingError::NumericFailure:
36  return "Numeric failure in calculation.";
37  case VertexingError::EmptyInput:
38  return "Empty input provided.";
39  case VertexingError::SeedingError:
40  return "Error while finding vertex seed.";
41  case VertexingError::NotConverged:
42  return "Unable to converge.";
43  case VertexingError::ElementNotFound:
44  return "Unable to find element.";
45  case VertexingError::NoCovariance:
46  return "No covariance provided.";
47  default:
48  return "unknown";
49  }
50  }
51 };
52 } // namespace detail
53 
54 // Declare a global function returning a static instance of the custom category
57  return c;
58 }
59 
60 inline std::error_code make_error_code(Acts::VertexingError e) {
61  return {static_cast<int>(e), Acts::VertexingErrorCategory()};
62 }
63 } // namespace Acts
64 
65 namespace std {
66 // register with STL
67 template <>
68 struct is_error_code_enum<Acts::VertexingError> : std::true_type {};
69 } // namespace std