MGIS 3.1.0
Loading...
Searching...
No Matches
mgis::ErrorBacktrace Struct Reference

a structure to keep trace of error messages. More...

#include </home/runner/work/MFrontGenericInterfaceSupport/MFrontGenericInterfaceSupport/include/MGIS/ErrorBacktrace.hxx>

Inheritance diagram for mgis::ErrorBacktrace:
mgis::AbstractErrorHandler mgis::Context

Public Types

using ErrorReportFunction = std::string (*)(const int)
 brief a simple alias
using ErrorReport
 a simple alias listing the main way to report an error.

Public Member Functions

void assertOrTerminate (const bool, const char *const)
 assert that the given boolean is true. If false, terminate is called.
void assertOrTerminate (const bool, const ErrorReport)
 assert that the given boolean is true. If false, terminate is called.
void terminate (const char *const)
 terminate the excution after displaying the given error message
void terminate (const ErrorReport)
 terminate the excution after displaying the given error message
InvalidResult registerErrorMessage (const char *const) final
 register a new error message
InvalidResult registerErrorMessage (const ErrorReport) MGIS_NOEXCEPT
 register a new error message
template<typename ReturnType>
requires (internal::InvalidValueTraits<ReturnType>::isSpecialized)
ReturnType registerErrorMessage (const char *const)
 register a new error message
template<typename ReturnType>
requires (internal::InvalidValueTraits<ReturnType>::isSpecialized)
ReturnType registerErrorMessage (const ErrorReport) MGIS_NOEXCEPT
 register a new error message
InvalidResult registerErrorMessageWithoutSourceLocation (const ErrorReport) MGIS_NOEXCEPT
 register a new error message
void clearErrorMessages () MGIS_NOEXCEPT
 remove the error messages
std::string getErrorMessage (const bool=true) MGIS_NOEXCEPT
std::string getRawErrorMessage (const bool=true) MGIS_NOEXCEPT
bool empty () const MGIS_NOEXCEPT
 ~ErrorBacktrace () noexcept override
 destructor
Public Member Functions inherited from mgis::AbstractErrorHandler
virtual constexpr ~AbstractErrorHandler ()=default
 destructor

Static Public Member Functions

static void setErrorReportingAsFatal () MGIS_NOEXCEPT
 specify if error reporting shall be fatal
static void unsetErrorReportingAsFatal () MGIS_NOEXCEPT
 specify if error reporting shall be fatal
static void abort (std::string_view)
 call the terminate handler

Detailed Description

a structure to keep trace of error messages.

The design of this class is inspired by the many solutions offered by the standard library (exceptions, std::error_code, etc...)

Member Typedef Documentation

◆ ErrorReport

Initial value:
std::
variant<const char *, std::pair<int, ErrorReportFunction>, std::string>

a simple alias listing the main way to report an error.

The alternatives way of reporting an error are:

  • a plain message in the form of a C-string
  • a message in the form of a std::string
  • an error code associated with a function allowing to retrieve an appropriate error message.

Building complex error message shall be avoided as much as possible in template code.

Member Function Documentation

◆ abort()

void mgis::ErrorBacktrace::abort ( std::string_view )
static

call the terminate handler

Parameters
[in]msgmessage
Note
this function is simply an alias to terminate

◆ assertOrTerminate() [1/2]

void mgis::ErrorBacktrace::assertOrTerminate ( const bool b,
const char * const msg )
inline

assert that the given boolean is true. If false, terminate is called.

Parameters
[in]btest
[in]eerror message

◆ assertOrTerminate() [2/2]

void mgis::ErrorBacktrace::assertOrTerminate ( const bool b,
const ErrorReport e )
inline

assert that the given boolean is true. If false, terminate is called.

Parameters
[in]btest
[in]eerror code

◆ empty()

bool mgis::ErrorBacktrace::empty ( ) const
nodiscard
Returns
if the list registered error messages is empty

◆ getErrorMessage()

std::string mgis::ErrorBacktrace::getErrorMessage ( const bool = true)
nodiscard
Returns
the registered error messages
Parameters
[in]bboolean. If true, the error message are cleared

◆ getRawErrorMessage()

std::string mgis::ErrorBacktrace::getRawErrorMessage ( const bool = true)
nodiscard
Returns
the error message without the decoration (file name, function name, line number)
Parameters
[in]bboolean. If true, the error message are cleared

◆ registerErrorMessage() [1/4]

template<typename ReturnType>
requires (internal::InvalidValueTraits<ReturnType>::isSpecialized)
ReturnType mgis::ErrorBacktrace::registerErrorMessage ( const char * const e)
nodiscardvirtual

register a new error message

Parameters
[in]eerror message
Note
for convenience, this method always return an invalid object

Implements mgis::AbstractErrorHandler.

◆ registerErrorMessage() [2/4]

InvalidResult mgis::ErrorBacktrace::registerErrorMessage ( const char * const )
nodiscardfinalvirtual

register a new error message

Parameters
[in]eerror message
Note
for convenience, this method always return an invalid object

Implements mgis::AbstractErrorHandler.

◆ registerErrorMessage() [3/4]

template<typename ReturnType>
requires (internal::InvalidValueTraits<ReturnType>::isSpecialized)
ReturnType mgis::ErrorBacktrace::registerErrorMessage ( const ErrorReport e)
nodiscard

register a new error message

Parameters
[in]eerror code
Note
for convenience, this method always return an invalid results

◆ registerErrorMessage() [4/4]

InvalidResult mgis::ErrorBacktrace::registerErrorMessage ( const ErrorReport )
nodiscard

register a new error message

Parameters
[in]eerror code
Note
for convenience, this method always return an invalid results

◆ registerErrorMessageWithoutSourceLocation()

InvalidResult mgis::ErrorBacktrace::registerErrorMessageWithoutSourceLocation ( const ErrorReport )
nodiscard

register a new error message

Parameters
[in]eerror code
Note
for convenience, this method always return InvalidResult

◆ terminate() [1/2]

void mgis::ErrorBacktrace::terminate ( const char * const )

terminate the excution after displaying the given error message

Parameters
[in]eerror message

◆ terminate() [2/2]

void mgis::ErrorBacktrace::terminate ( const ErrorReport )

terminate the excution after displaying the given error message

Parameters
[in]eerror code

The documentation for this struct was generated from the following files: