ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EigenStepperError.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EigenStepperError.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 EigenStepperError {
18  StepSizeStalled = 1,
19  StepInvalid = 2,
20  StepSizeAdjustmentFailed = 3
21 };
22 
23 namespace detail {
24 // Define a custom error code category derived from std::error_category
25 class EigenStepperErrorCategory : public std::error_category {
26  public:
27  // Return a short descriptive name for the category
28  const char* name() const noexcept final { return "EigenStepperError"; }
29  // Return what each enum means in text
30  std::string message(int c) const final {
31  switch (static_cast<EigenStepperError>(c)) {
32  case EigenStepperError::StepSizeStalled:
33  return "Step size fell below minimum threshold";
34  case EigenStepperError::StepInvalid:
35  return "Step calculation was invalid";
36  case EigenStepperError::StepSizeAdjustmentFailed:
37  return "Step size adjustment exceeds maximum trials";
38  default:
39  return "unknown";
40  }
41  }
42 };
43 } // namespace detail
44 
45 // Declare a global function returning a static instance of the custom category
46 extern inline const detail::EigenStepperErrorCategory&
49  return c;
50 }
51 
52 inline std::error_code make_error_code(Acts::EigenStepperError e) {
53  return {static_cast<int>(e), Acts::EigenStepperErrorCategory()};
54 }
55 } // namespace Acts
56 
57 namespace std {
58 // register with STL
59 template <>
60 struct is_error_code_enum<Acts::EigenStepperError> : std::true_type {};
61 } // namespace std