mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Make Error classes header only
This commit is contained in:
parent
4af0954ae9
commit
f2dce91098
|
@ -117,7 +117,6 @@ if(BUILD_FAIRMQ)
|
||||||
Channel.cxx
|
Channel.cxx
|
||||||
Device.cxx
|
Device.cxx
|
||||||
DeviceRunner.cxx
|
DeviceRunner.cxx
|
||||||
Error.cxx
|
|
||||||
JSONParser.cxx
|
JSONParser.cxx
|
||||||
MemoryResources.cxx
|
MemoryResources.cxx
|
||||||
Plugin.cxx
|
Plugin.cxx
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/********************************************************************************
|
|
||||||
* Copyright (C) 2019-2021 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::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";
|
|
||||||
case ErrorCode::DeviceGetPropertiesFailed:
|
|
||||||
return "failed to get fairmq device properties";
|
|
||||||
case ErrorCode::DeviceSetPropertiesFailed:
|
|
||||||
return "failed to set fairmq device properties";
|
|
||||||
default:
|
|
||||||
return "(unrecognized error)";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ErrorCategory errorCategory{};
|
|
||||||
|
|
||||||
std::error_code MakeErrorCode(ErrorCode e) { return {static_cast<int>(e), errorCategory}; }
|
|
||||||
|
|
||||||
} // namespace fair::mq
|
|
|
@ -38,14 +38,34 @@ enum class ErrorCode
|
||||||
DeviceSetPropertiesFailed
|
DeviceSetPropertiesFailed
|
||||||
};
|
};
|
||||||
|
|
||||||
std::error_code MakeErrorCode(ErrorCode);
|
|
||||||
|
|
||||||
struct ErrorCategory : std::error_category
|
struct ErrorCategory : std::error_category
|
||||||
{
|
{
|
||||||
const char* name() const noexcept override;
|
const char* name() const noexcept override { return "fairmq"; }
|
||||||
std::string message(int ev) const override;
|
std::string message(int ev) const override
|
||||||
|
{
|
||||||
|
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";
|
||||||
|
case ErrorCode::DeviceGetPropertiesFailed:
|
||||||
|
return "failed to get fairmq device properties";
|
||||||
|
case ErrorCode::DeviceSetPropertiesFailed:
|
||||||
|
return "failed to set fairmq device properties";
|
||||||
|
default:
|
||||||
|
return "(unrecognized error)";
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static ErrorCategory ec;
|
||||||
|
|
||||||
|
inline std::error_code MakeErrorCode(ErrorCode e) { return {static_cast<int>(e), ec}; }
|
||||||
|
|
||||||
} // namespace fair::mq
|
} // namespace fair::mq
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user