SDK: Introduce fairmq error category

This commit is contained in:
Dennis Klein
2019-08-20 16:33:51 +02:00
committed by Dennis Klein
parent f73a6d71ed
commit 25539e99f2
5 changed files with 77 additions and 11 deletions

40
fairmq/sdk/Error.cxx Normal file
View 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