 |
LibraryLink Utilities
3.0.1
Modern C++ wrapper over LibraryLink and WSTP
|
Go to the documentation of this file.
8 #ifndef LLU_ERRORLOG_LIBRARYLINKERROR_H_
9 #define LLU_ERRORLOG_LIBRARYLINKERROR_H_
59 debugInfo = std::runtime_error {dbg};
79 [[nodiscard]] std::string
name() const noexcept {
86 [[nodiscard]] std::string
message() const noexcept {
87 return messageTemplate.what();
93 [[nodiscard]] std::string
debug() const noexcept {
94 return debugInfo.what();
104 template<
typename... T>
143 : std::runtime_error(t), errorId(
which), messageTemplate(msg.c_str()) {}
150 static WSLINK openLoopback(WSENV env);
153 static constexpr
const char* exceptionDetailsSymbol =
"$LastFailureParameters";
156 static std::string exceptionDetailsSymbolContext;
159 std::runtime_error messageTemplate;
160 std::runtime_error debugInfo {
""};
161 WSLINK messageParams =
nullptr;
164 template<
typename... T>
166 messageParams = openLoopback(libData->getWSLINKEnvironment(libData));
167 if (!messageParams) {
171 constexpr
auto messageParamsCount =
sizeof...(T);
172 loopback << WS::List(static_cast<int>(messageParamsCount));
173 Unused((loopback << ... << params));
static void setExceptionDetailsSymbolContext(std::string newContext)
Set custom context for the Wolfram Language symbol that will hold the details of last thrown exceptio...
Definition: LibraryLinkError.cpp:18
void setDebugInfo(const std::string &dbg)
Set debug info.
Definition: LibraryLinkError.h:58
Main namespace of LibraryLink Utilities.
Definition: Queue.h:13
Wrapper class over WSTP with a stream-like interface.
Definition: WSTP/Utilities.h:21
LibraryLinkError & operator=(const LibraryLinkError &e) noexcept
Copy-assignment operator.
Definition: LibraryLinkError.cpp:53
IdType sendParameters(WolframLibraryData libData, const std::string &WLSymbol=getExceptionDetailsSymbol()) const noexcept
Send parameters stored in the loopback link to top-level.
Definition: LibraryLinkError.cpp:84
IdType which() const noexcept
Alias for id() to preserve backwards compatibility.
Definition: LibraryLinkError.h:72
std::string message() const noexcept
Get the value of error code.
Definition: LibraryLinkError.h:86
Header file for WSStream class.
Class representing an exception in paclet code.
Definition: LibraryLinkError.h:32
static const std::string & getExceptionDetailsSymbolContext()
Get current context of the symbol that will hold the details of last thrown exception.
Definition: LibraryLinkError.cpp:22
void Unused(Ts &&...)
Dummy function called on otherwise unused parameters to eliminate compiler warnings.
Definition: Utilities.hpp:115
~LibraryLinkError() override
The destructor closes the link that was used to send message parameters, if any.
Definition: LibraryLinkError.cpp:78
std::string name() const noexcept
Get the value of error code.
Definition: LibraryLinkError.h:79
std::string debug() const noexcept
Get debug info.
Definition: LibraryLinkError.h:93
static std::string getExceptionDetailsSymbol()
Get symbol that will hold details of last thrown exception.
Definition: LibraryLinkError.cpp:26
LibraryLinkError(const LibraryLinkError &e) noexcept
Copy-constructor. If there are any messages parameters on the WSLINK, a deep copy is performed.
Definition: LibraryLinkError.cpp:39
IdType id() const noexcept
Get the value of error code.
Definition: LibraryLinkError.h:65
void setMessageParameters(WolframLibraryData libData, T &&... params)
Store arbitrary number of message parameters in a List expression on a loopback link.
Definition: LibraryLinkError.h:165
int IdType
A type that holds error id numbers.
Definition: LibraryLinkError.h:37
"Static" class responsible for error registration and throwing
Definition: ErrorManager.h:30