FairMQ  1.4.33
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::mq
17 {
18 
19 namespace sdk
20 {
21 
22 struct RuntimeError : ::std::runtime_error
23 {
24  template<typename... T>
25  explicit RuntimeError(T&&... t)
26  : ::std::runtime_error::runtime_error(tools::ToString(std::forward<T>(t)...))
27  {}
28 };
29 
30 } /* namespace sdk */
31 
32 enum class ErrorCode
33 {
34  OperationInProgress = 10,
35  OperationTimeout,
36  OperationCanceled,
37  DeviceChangeStateFailed,
38  DeviceGetPropertiesFailed,
39  DeviceSetPropertiesFailed
40 };
41 
42 std::error_code MakeErrorCode(ErrorCode);
43 
44 struct ErrorCategory : std::error_category
45 {
46  const char* name() const noexcept override;
47  std::string message(int ev) const override;
48 };
49 
50 } // namespace fair::mq
51 
52 namespace std
53 {
54 
55 template<>
56 struct is_error_code_enum<fair::mq::ErrorCode> : true_type
57 {};
58 
59 } // namespace std
60 
61 #endif /* FAIR_MQ_SDK_ERROR_H */
fair::mq
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23
fair::mq::ErrorCategory
Definition: Error.h:51

privacy