mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
SDK: Introduce fairmq error category
This commit is contained in:
parent
f73a6d71ed
commit
25539e99f2
|
@ -14,7 +14,7 @@
|
|||
#include <asio/executor_work_guard.hpp>
|
||||
#include <asio/system_executor.hpp>
|
||||
#include <chrono>
|
||||
#include <fairmq/sdk/Exceptions.h>
|
||||
#include <fairmq/sdk/Error.h>
|
||||
#include <fairmq/sdk/Traits.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
|
|
@ -30,6 +30,7 @@ set(SDK_SOURCE_FILES
|
|||
DDSEnvironment.cxx
|
||||
DDSSession.cxx
|
||||
DDSTopology.cxx
|
||||
Error.cxx
|
||||
Topology.cxx
|
||||
)
|
||||
|
||||
|
|
40
fairmq/sdk/Error.cxx
Normal file
40
fairmq/sdk/Error.cxx
Normal file
|
@ -0,0 +1,40 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "Error.h"
|
||||
|
||||
namespace fair {
|
||||
namespace mq {
|
||||
|
||||
const char* ErrorCategory::name() const noexcept
|
||||
{
|
||||
return "fairmq";
|
||||
}
|
||||
|
||||
std::string ErrorCategory::message(int ev) const
|
||||
{
|
||||
switch (static_cast<ErrorCode>(ev)) {
|
||||
case ErrorCode::OperationInProgress:
|
||||
return "async operation already in progress";
|
||||
case ErrorCode::OperationTimeout:
|
||||
return "async operation timed out";
|
||||
case ErrorCode::OperationCanceled:
|
||||
return "async operation canceled";
|
||||
case ErrorCode::DeviceChangeStateFailed:
|
||||
return "failed to change state of a fairmq device";
|
||||
default:
|
||||
return "(unrecognized error)";
|
||||
}
|
||||
}
|
||||
|
||||
const ErrorCategory errorCategory{};
|
||||
|
||||
std::error_code MakeErrorCode(ErrorCode e) { return {static_cast<int>(e), errorCategory}; }
|
||||
|
||||
} // namespace mq
|
||||
} // namespace fair
|
|
@ -6,8 +6,8 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef FAIR_MQ_SDK_EXCEPTIONS_H
|
||||
#define FAIR_MQ_SDK_EXCEPTIONS_H
|
||||
#ifndef FAIR_MQ_SDK_ERROR_H
|
||||
#define FAIR_MQ_SDK_ERROR_H
|
||||
|
||||
#include <fairmq/Tools.h>
|
||||
#include <stdexcept>
|
||||
|
@ -31,7 +31,32 @@ struct MixedStateError : RuntimeError
|
|||
};
|
||||
|
||||
} /* namespace sdk */
|
||||
|
||||
enum class ErrorCode
|
||||
{
|
||||
OperationInProgress = 10,
|
||||
OperationTimeout,
|
||||
OperationCanceled,
|
||||
DeviceChangeStateFailed
|
||||
};
|
||||
|
||||
std::error_code MakeErrorCode(ErrorCode);
|
||||
|
||||
struct ErrorCategory : std::error_category
|
||||
{
|
||||
const char* name() const noexcept override;
|
||||
std::string message(int ev) const override;
|
||||
};
|
||||
|
||||
} /* namespace mq */
|
||||
} /* namespace fair */
|
||||
|
||||
#endif /* FAIR_MQ_SDK_EXCEPTIONS_H */
|
||||
namespace std {
|
||||
|
||||
template<>
|
||||
struct is_error_code_enum<fair::mq::ErrorCode> : true_type
|
||||
{};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif /* FAIR_MQ_SDK_ERROR_H */
|
|
@ -9,20 +9,20 @@
|
|||
#ifndef FAIR_MQ_SDK_TOPOLOGY_H
|
||||
#define FAIR_MQ_SDK_TOPOLOGY_H
|
||||
|
||||
#include <chrono>
|
||||
#include <fairmq/States.h>
|
||||
#include <fairmq/Tools.h>
|
||||
#include <fairmq/sdk/DDSInfo.h>
|
||||
#include <fairmq/sdk/DDSSession.h>
|
||||
#include <fairmq/sdk/DDSTopology.h>
|
||||
#include <fairmq/States.h>
|
||||
#include <fairmq/Tools.h>
|
||||
|
||||
#include <fairmq/sdk/Error.h>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <chrono>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace fair {
|
||||
namespace mq {
|
||||
|
|
Loading…
Reference in New Issue
Block a user