AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AFatalException Class Reference

An exception that thrown when non-c++ unhandled error occurs (i.e. access violation). More...

#include <AUI/Common/AFatalException.h>

Public Types

using Handler = std::function<void(AFatalException*)>
 

Public Member Functions

 AFatalException (std::string_view signalName, int nativeSignalId)
 
AString getMessage () const noexcept override
 
void * address () const
 
int nativeSignalId () const
 
std::string_view signalName () const
 
- Public Member Functions inherited from AException
 AException (AStacktrace stacktrace)
 
 AException (const AString &message)
 
 AException (const AString &message, std::exception_ptr causedBy, AStacktrace stacktrace=AStacktrace::capture(2))
 
const char * what () const noexcept override
 
const AStacktracestacktrace () const noexcept
 
const std::exception_ptr & causedBy () const noexcept
 

Static Public Member Functions

static void setGlobalHandler (Handler globalHandler)
 Sets handler for fatal exceptions.
 

Detailed Description

An exception that thrown when non-c++ unhandled error occurs (i.e. access violation).

Note
AFatalException::setGlobalHandler is supported on all platforms, but translation to AFatalError is not as it uses compiler-specific flags and hacks. See Platform support for further info.

Translation to throwing AFatalException recovers the application from crashed state, providing you ability to handle such errors and continue normal application execution. However, still recommended to handle such errors with setGlobalHandler() to at least save user data.

Platform support

Platform Translation to throwing AFatalException setGlobalHandler()
Windows MSVC +
Linux GCC +
macOS - +
Android GCC +
iOS - +

Member Function Documentation

◆ address()

void * AFatalException::address ( ) const
inline
Returns
Address where does the fatal exception occurred.

◆ getMessage()

AString AFatalException::getMessage ( ) const
overridevirtualnoexcept

Reimplemented from AException.

◆ nativeSignalId()

int AFatalException::nativeSignalId ( ) const
inline
Returns
Native signal id.

◆ setGlobalHandler()

static void AFatalException::setGlobalHandler ( Handler globalHandler)
inlinestatic

Sets handler for fatal exceptions.

Parameters
globalHandlerhandler

The handler is called inside OS's signal callback, thus, it's not recommended to use the following operations during callback execution:

  • I/O (printf, logging, fopen, fread, fwrite, etc...)
  • Heap routines (malloc, free, new, delete), including heap-based containers (std::vector, std::list, std::queue, etc...)
  • System calls (time, getcwd, etc...)

Basically, you may want to define global AOptional<AFatalException> and store the copy of exception in order to process it outside of the callback.

The callback may be used for handling and sending telemetry data (however, be aware of using unrecommended operations).

◆ signalName()

std::string_view AFatalException::signalName ( ) const
inline
Returns
Signal name.

The documentation for this class was generated from the following files:
Inheritance diagram for AFatalException:
Collaboration diagram for AFatalException: