FairMQ  1.4.14
C++ Message Queuing Library and Framework
Error.h
1 /********************************************************************************
2  * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef FAIR_MQ_SDK_ERROR_H
10 #define FAIR_MQ_SDK_ERROR_H
11 
12 #include <fairmq/tools/Strings.h>
13 #include <stdexcept>
14 #include <system_error>
15 
16 namespace fair {
17 namespace mq {
18 namespace sdk {
19 
20 struct RuntimeError : ::std::runtime_error
21 {
22  template<typename... T>
23  explicit RuntimeError(T&&... t)
24  : ::std::runtime_error::runtime_error(tools::ToString(std::forward<T>(t)...))
25  {}
26 };
27 
29 {
30  using RuntimeError::RuntimeError;
31 };
32 
33 } /* namespace sdk */
34 
35 enum class ErrorCode
36 {
37  OperationInProgress = 10,
38  OperationTimeout,
39  OperationCanceled,
40  DeviceChangeStateFailed,
41  DeviceGetPropertiesFailed,
42  DeviceSetPropertiesFailed
43 };
44 
45 std::error_code MakeErrorCode(ErrorCode);
46 
47 struct ErrorCategory : std::error_category
48 {
49  const char* name() const noexcept override;
50  std::string message(int ev) const override;
51 };
52 
53 } /* namespace mq */
54 } /* namespace fair */
55 
56 namespace std {
57 
58 template<>
59 struct is_error_code_enum<fair::mq::ErrorCode> : true_type
60 {};
61 
62 } // namespace std
63 
64 #endif /* FAIR_MQ_SDK_ERROR_H */
Definition: Error.h:56
Definition: Error.h:28
Definition: Error.h:47
Definition: Error.h:20
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23

privacy