MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
Exception.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project.
2//
3// SPDX-License-Identifier: Apache-2.0
4
5#include "Exception.hpp"
6#include <rdma/fi_errno.h>
7#include "mxl/mxl.h"
8
10{
12 : _msg(std::move(msg))
14 {}
15
17 {
18 return _status;
19 }
20
21 char const* Exception::what() const noexcept
22 {
23 return _msg.c_str();
24 }
25
27 : Exception(std::move(msg), status)
29 {}
30
31 int FabricException::fiErrno() const noexcept
32 {
33 return _fiErrno;
34 }
35
36 bool FabricException::isInterrupted() const noexcept
37 {
38 return _fiErrno == -FI_EINTR;
39 }
40
42 {
43 switch (fiErrno)
44 {
45 case -FI_EINTR: return MXL_ERR_INTERRUPTED;
46 case -FI_EAGAIN: return MXL_ERR_NOT_READY;
47 case -FI_ENOSYS: return MXL_ERR_UNSUPPORTED_OPERATION;
48 default: return MXL_ERR_UNKNOWN;
49 }
50 }
51}
char const * what() const noexcept override
Implements std::exception, returns a descriptive string about the error.
Definition Exception.cpp:21
Exception(std::string msg, mxlStatus status)
Definition Exception.cpp:11
mxlStatus status() const noexcept
Return the mxlStatus status code that describes the condition that led to the exception being thrown.
Definition Exception.cpp:16
FabricException(std::string msg, mxlStatus status, int fiErrno)
Definition Exception.cpp:26
mxlStatus
MXL SDK Status codes.
Definition mxl.h:22
@ MXL_ERR_NOT_READY
Definition mxl.h:49
@ MXL_ERR_UNKNOWN
Definition mxl.h:27
@ MXL_ERR_INTERRUPTED
Definition mxl.h:45
@ MXL_ERR_UNSUPPORTED_OPERATION
Definition mxl.h:52
mxlStatus mxlStatusFromFiErrno(int fiErrno)
Convert an error code returned by libfabric to an appropriate mxlStatus code.
Definition Exception.cpp:41