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/executor_work_guard.hpp>
|
||||||
#include <asio/system_executor.hpp>
|
#include <asio/system_executor.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <fairmq/sdk/Exceptions.h>
|
#include <fairmq/sdk/Error.h>
|
||||||
#include <fairmq/sdk/Traits.h>
|
#include <fairmq/sdk/Traits.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
|
@ -30,6 +30,7 @@ set(SDK_SOURCE_FILES
|
||||||
DDSEnvironment.cxx
|
DDSEnvironment.cxx
|
||||||
DDSSession.cxx
|
DDSSession.cxx
|
||||||
DDSTopology.cxx
|
DDSTopology.cxx
|
||||||
|
Error.cxx
|
||||||
Topology.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" *
|
* copied verbatim in the file "LICENSE" *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#ifndef FAIR_MQ_SDK_EXCEPTIONS_H
|
#ifndef FAIR_MQ_SDK_ERROR_H
|
||||||
#define FAIR_MQ_SDK_EXCEPTIONS_H
|
#define FAIR_MQ_SDK_ERROR_H
|
||||||
|
|
||||||
#include <fairmq/Tools.h>
|
#include <fairmq/Tools.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -31,7 +31,32 @@ struct MixedStateError : RuntimeError
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace sdk */
|
} /* 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 mq */
|
||||||
} /* namespace fair */
|
} /* 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
|
#ifndef FAIR_MQ_SDK_TOPOLOGY_H
|
||||||
#define 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/DDSInfo.h>
|
||||||
#include <fairmq/sdk/DDSSession.h>
|
#include <fairmq/sdk/DDSSession.h>
|
||||||
#include <fairmq/sdk/DDSTopology.h>
|
#include <fairmq/sdk/DDSTopology.h>
|
||||||
#include <fairmq/States.h>
|
#include <fairmq/sdk/Error.h>
|
||||||
#include <fairmq/Tools.h>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <unordered_map>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <chrono>
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace fair {
|
namespace fair {
|
||||||
namespace mq {
|
namespace mq {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user