LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
LLU::LibraryLinkError Class Reference

Description

Class representing an exception in paclet code.

All exceptions that are thrown from paclet code should be of this class. To prevent users from overriding predefined LLU exceptions the constructor of LibraryLinkError class is private. Developers should use ErrorManager::throwException method to throw exceptions.

Inherits runtime_error.

#include <LibraryLinkError.h>

Public Types

using IdType = int
 A type that holds error id numbers. More...
 

Public Member Functions

 LibraryLinkError (const LibraryLinkError &e) noexcept
 Copy-constructor. If there are any messages parameters on the WSLINK, a deep copy is performed. More...
 
LibraryLinkErroroperator= (const LibraryLinkError &e) noexcept
 Copy-assignment operator. More...
 
 LibraryLinkError (LibraryLinkError &&e) noexcept
 Move-constructor. Steals messagesParams from e. More...
 
LibraryLinkErroroperator= (LibraryLinkError &&e) noexcept
 Move-assignment operator. More...
 
 ~LibraryLinkError () override
 The destructor closes the link that was used to send message parameters, if any. More...
 
void setDebugInfo (const std::string &dbg)
 Set debug info. More...
 
IdType id () const noexcept
 Get the value of error code. More...
 
IdType which () const noexcept
 Alias for id() to preserve backwards compatibility. More...
 
std::string name () const noexcept
 Get the value of error code. More...
 
std::string message () const noexcept
 Get the value of error code. More...
 
std::string debug () const noexcept
 Get debug info. More...
 
template<typename... T>
void setMessageParameters (WolframLibraryData libData, T &&... params)
 Store arbitrary number of message parameters in a List expression on a loopback link. More...
 
IdType sendParameters (WolframLibraryData libData, const std::string &WLSymbol=getExceptionDetailsSymbol()) const noexcept
 Send parameters stored in the loopback link to top-level. More...
 

Static Public Member Functions

static std::string getExceptionDetailsSymbol ()
 Get symbol that will hold details of last thrown exception. More...
 
static void setExceptionDetailsSymbolContext (std::string newContext)
 Set custom context for the Wolfram Language symbol that will hold the details of last thrown exception. More...
 
static const std::string & getExceptionDetailsSymbolContext ()
 Get current context of the symbol that will hold the details of last thrown exception. More...
 

Friends

class ErrorManager
 

Type aliases documentation

◆ IdType

A type that holds error id numbers.

Constructor & Destructor Documentation

◆ LibraryLinkError() [1/2]

LLU::LibraryLinkError::LibraryLinkError ( const LibraryLinkError e)
noexcept

Copy-constructor. If there are any messages parameters on the WSLINK, a deep copy is performed.

◆ LibraryLinkError() [2/2]

LLU::LibraryLinkError::LibraryLinkError ( LibraryLinkError &&  e)
noexcept

Move-constructor. Steals messagesParams from e.

◆ ~LibraryLinkError()

LLU::LibraryLinkError::~LibraryLinkError ( )
override

The destructor closes the link that was used to send message parameters, if any.

Member Function Documentation

◆ debug()

std::string LLU::LibraryLinkError::debug ( ) const
inlinenoexcept

Get debug info.

◆ getExceptionDetailsSymbol()

std::string LLU::LibraryLinkError::getExceptionDetailsSymbol ( )
static

Get symbol that will hold details of last thrown exception.

Returns
a WL symbol

◆ getExceptionDetailsSymbolContext()

const std::string & LLU::LibraryLinkError::getExceptionDetailsSymbolContext ( )
static

Get current context of the symbol that will hold the details of last thrown exception.

Returns
a WL context

◆ id()

IdType LLU::LibraryLinkError::id ( ) const
inlinenoexcept

Get the value of error code.

◆ message()

std::string LLU::LibraryLinkError::message ( ) const
inlinenoexcept

Get the value of error code.

◆ name()

std::string LLU::LibraryLinkError::name ( ) const
inlinenoexcept

Get the value of error code.

◆ operator=() [1/2]

LibraryLinkError & LLU::LibraryLinkError::operator= ( const LibraryLinkError e)
noexcept

Copy-assignment operator.

◆ operator=() [2/2]

LibraryLinkError & LLU::LibraryLinkError::operator= ( LibraryLinkError &&  e)
noexcept

Move-assignment operator.

◆ sendParameters()

auto LLU::LibraryLinkError::sendParameters ( WolframLibraryData  libData,
const std::string &  WLSymbol = getExceptionDetailsSymbol() 
) const
noexcept

Send parameters stored in the loopback link to top-level.

They will be assigned as a List to symbol passed in WLSymbol parameter.

Parameters
libData- WolframLibraryData, if nullptr, the parameters will not be send
WLSymbol- symbol to assign parameters to in top-level
Returns
LLErrorCode because this function is noexcept

◆ setDebugInfo()

void LLU::LibraryLinkError::setDebugInfo ( const std::string &  dbg)
inline

Set debug info.

Parameters
dbg- additional information helpful in debugging

◆ setExceptionDetailsSymbolContext()

void LLU::LibraryLinkError::setExceptionDetailsSymbolContext ( std::string  newContext)
static

Set custom context for the Wolfram Language symbol that will hold the details of last thrown exception.

Parameters
newContext- any valid WL context, it must end with a backtick (`)

◆ setMessageParameters()

template<typename... T>
void LLU::LibraryLinkError::setMessageParameters ( WolframLibraryData  libData,
T &&...  params 
)

Store arbitrary number of message parameters in a List expression on a loopback link.

They will travel with the exception until sendParameters is called on the exception.

Template Parameters
T- any type(s) that WSStream supports
Parameters
libData- WolframLibraryData, if nullptr, the parameters will not be send
params- any number of message parameters

◆ which()

IdType LLU::LibraryLinkError::which ( ) const
inlinenoexcept

Alias for id() to preserve backwards compatibility.