geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
Exception.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - 2024 Intel Corporation
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef EXCEPTION_HPP_INCLUDE
6 #define EXCEPTION_HPP_INCLUDE
7 
8 #include <stdexcept>
9 #include <string>
10 
11 #include "geopm_error.h"
12 #include "geopm_public.h"
13 
14 namespace geopm
15 {
37  int GEOPM_PUBLIC
38  exception_handler(std::exception_ptr eptr, bool do_print = false);
39 
47  class GEOPM_PUBLIC Exception : public std::runtime_error
48  {
49  public:
55  Exception();
56  Exception(const Exception &other);
57  Exception &operator=(const Exception &other);
81  Exception(const std::string &what, int err, const char *file, int line);
83  virtual ~Exception() = default;
94  int err_value(void) const;
95  private:
97  int m_err;
98  };
99 
105  std::string GEOPM_PUBLIC
106  error_message(int error_value);
107 }
108 
109 #endif
Class for all GEOPM-specific exceptions.
Definition: Exception.hpp:48
virtual ~Exception()=default
Exception destructor, virtual.
#define GEOPM_PUBLIC
Definition: geopm_public.h:10
Definition: Agg.cpp:20
int exception_handler(std::exception_ptr eptr, bool do_print)
Handle a thrown exception and return an error value.
Definition: Exception.cpp:60
std::string error_message(int error_value)
Function that converts an error code into an error message.
Definition: Exception.cpp:55