Safir SDK Core
Loading...
Searching...
No Matches
Safir::Dob::Typesystem::LibraryExceptions Class Reference

Contains methods used when passing exceptions across language boundaries. More...

#include <Safir/Dob/Typesystem/LibraryExceptions.h>

Public Member Functions

void Set (const FundamentalException &exception)
 Set the current exception.
 
void Set (const Exception &exception)
 Set the current exception.
 
void Set (const std::exception &exception)
 Set the current exception.
 
void SetUnknown ()
 Set the current exception.
 
void AppendDescription (const std::wstring &moreDescription)
 Append some text to the description of the current exception.
 
void Throw ()
 Throw the current exception.
 
void Throw (const TypeId exceptionId, const std::string &description) const
 Throw a specific exception.
 

Static Public Member Functions

static LibraryExceptionsInstance ()
 Get the instance of the singleton.
 

Registration part.

Stuff for registering exceptions with the exception factory.

typedef void(* ThrowExceptionCallback) (const std::wstring &description)
 Function signature of the throw exception callback function.
 
bool RegisterException (const TypeId exceptionId, ThrowExceptionCallback throwFunction)
 Register an exception with the object factory.
 

Detailed Description

Contains methods used when passing exceptions across language boundaries.

Member Typedef Documentation

◆ ThrowExceptionCallback

typedef void(* Safir::Dob::Typesystem::LibraryExceptions::ThrowExceptionCallback) (const std::wstring &description)

Function signature of the throw exception callback function.

This is the signature of the function that the exception factory will call to throw an exception of a type.

Member Function Documentation

◆ AppendDescription()

void Safir::Dob::Typesystem::LibraryExceptions::AppendDescription ( const std::wstring & moreDescription)

Append some text to the description of the current exception.

This can be used just inside a language boundary to add extra information to the exception so that it is easier to debug the exception.

◆ Instance()

static LibraryExceptions & Safir::Dob::Typesystem::LibraryExceptions::Instance ( )
static

Get the instance of the singleton.

Returns
The instance of the singleton.

◆ RegisterException()

bool Safir::Dob::Typesystem::LibraryExceptions::RegisterException ( const TypeId exceptionId,
ThrowExceptionCallback throwFunction )

Register an exception with the object factory.

Only for use by the automatically generated code!

Parameters
exceptionId[in] - The TypeId of the exception that should be thrown using throwFunction.
throwFunction[in] - The function to call to throw the exception.

◆ Set() [1/3]

void Safir::Dob::Typesystem::LibraryExceptions::Set ( const Exception & exception)

Set the current exception.

When you have caught an exception that you would like to pass across language boundaries, call this method with the exception. Then, on the other side of the language boundary, call the Throw method, which will throw the exception in the other language.

The easiest way of doing this is to use the CATCH_LIBRARY_EXCEPTIONS macro above using code like this: { success = false; try { do your stuff here; success = true; } CATCH_LIBRARY_EXCEPTIONS; }

The success flag should be passed across the language boundary so that the Throw method can be called when an exception has occurred. The CATCH_LIBRARY_EXCEPTIONS catches all C++ exceptions and puts them into the LibraryExceptions singleton.

Parameters
exception[in] - The exception.

◆ Set() [2/3]

void Safir::Dob::Typesystem::LibraryExceptions::Set ( const FundamentalException & exception)

Set the current exception.

When you have caught an exception that you would like to pass across language boundaries, call this method with the exception. Then, on the other side of the language boundary, call the Throw method, which will throw the exception in the other language.

The easiest way of doing this is to use the CATCH_LIBRARY_EXCEPTIONS macro above using code like this: { success = false; try { do your stuff here; success = true; } CATCH_LIBRARY_EXCEPTIONS; }

The success flag should be passed across the language boundary so that the Throw method can be called when an exception has occurred. The CATCH_LIBRARY_EXCEPTIONS catches all C++ exceptions and puts them into the LibraryExceptions singleton.

Parameters
exception[in] - The exception.

◆ Set() [3/3]

void Safir::Dob::Typesystem::LibraryExceptions::Set ( const std::exception & exception)

Set the current exception.

When you have caught an exception that you would like to pass across language boundaries, call this method with the exception. Then, on the other side of the language boundary, call the Throw method, which will throw the exception in the other language.

The easiest way of doing this is to use the CATCH_LIBRARY_EXCEPTIONS macro above using code like this: { success = false; try { do your stuff here; success = true; } CATCH_LIBRARY_EXCEPTIONS; }

The success flag should be passed across the language boundary so that the Throw method can be called when an exception has occurred. The CATCH_LIBRARY_EXCEPTIONS catches all C++ exceptions and puts them into the LibraryExceptions singleton.

Parameters
exception[in] - The exception.

◆ SetUnknown()

void Safir::Dob::Typesystem::LibraryExceptions::SetUnknown ( )

Set the current exception.

This should be used when a ... exception is caught.

The easiest way of doing this is to use the CATCH_LIBRARY_EXCEPTIONS macro above using code like this: { success = false; try { do your stuff here; success = true; } CATCH_LIBRARY_EXCEPTIONS; }

The success flag should be passed across the language boundary so that the Throw method can be called when an exception has occurred. The CATCH_LIBRARY_EXCEPTIONS catches all C++ exceptions and puts them into the LibraryExceptions singleton.

◆ Throw() [1/2]

void Safir::Dob::Typesystem::LibraryExceptions::Throw ( )

Throw the current exception.

Call this to throw the current exception. It is considered a programming error to call this function if no exception is set.

◆ Throw() [2/2]

void Safir::Dob::Typesystem::LibraryExceptions::Throw ( const TypeId exceptionId,
const std::string & description ) const

Throw a specific exception.

This function takes no notice of currently set exceptions. Rather it throws the specified exception with the specified description string.

Parameters
exceptionId[in] - The TypeId of the exception to throw.
description[in] - String with more information about what happened. This is expected to be ascii if exceptionId == 0, and utf8 if exceptionId != 0.