libctru  v1.6.0
Data Structures | Enumerations | Functions
errf.h File Reference

Error Display API. More...

#include <3ds/types.h>

Go to the source code of this file.

Data Structures

struct  ERRF_ExceptionInfo
 
struct  ERRF_ExceptionData
 
struct  ERRF_FatalErrInfo
 

Enumerations

enum  ERRF_ErrType {
  ERRF_ERRTYPE_GENERIC = 0,
  ERRF_ERRTYPE_MEM_CORRUPT = 1,
  ERRF_ERRTYPE_CARD_REMOVED = 2,
  ERRF_ERRTYPE_EXCEPTION = 3,
  ERRF_ERRTYPE_FAILURE = 4,
  ERRF_ERRTYPE_LOGGED = 5
}
 Types of errors that can be thrown by err:f. More...
 
enum  ERRF_ExceptionType {
  ERRF_EXCEPTION_PREFETCH_ABORT = 0,
  ERRF_EXCEPTION_DATA_ABORT = 1,
  ERRF_EXCEPTION_UNDEFINED = 2,
  ERRF_EXCEPTION_VFP = 3
}
 Types of 'Exceptions' thrown for ERRF_ERRTYPE_EXCEPTION. More...
 

Functions

Result errfInit (void)
 Initializes ERR:f. Unless you plan to call ERRF_Throw yourself, do not use this.
 
void errfExit (void)
 Exits ERR:f. Unless you plan to call ERRF_Throw yourself, do not use this.
 
HandleerrfGetSessionHandle (void)
 Gets the current err:f API session handle. More...
 
Result ERRF_Throw (const ERRF_FatalErrInfo *error)
 Throws a system error and possibly results in ErrDisp triggering. More...
 
Result ERRF_ThrowResult (Result failure)
 Throws a system error with the given Result code. More...
 
Result ERRF_ThrowResultWithMessage (Result failure, const char *message)
 Throws a system error with the given Result code and message. More...
 
void ERRF_ExceptionHandler (ERRF_ExceptionInfo *excep, CpuRegisters *regs) __attribute__((noreturn))
 Handles an exception using ErrDisp. More...
 

Detailed Description

Error Display API.

Enumeration Type Documentation

◆ ERRF_ErrType

Types of errors that can be thrown by err:f.

Enumerator
ERRF_ERRTYPE_GENERIC 

For generic errors. Shows miscellaneous info.

ERRF_ERRTYPE_MEM_CORRUPT 

Same output as generic, but informs the user that "the System Memory has been damaged".

ERRF_ERRTYPE_CARD_REMOVED 

Displays the "The Game Card was removed." message.

ERRF_ERRTYPE_EXCEPTION 

For exceptions, or more specifically 'crashes'. union data should be exception_data.

ERRF_ERRTYPE_FAILURE 

For general failure. Shows a message. union data should have a string set in failure_mesg.

ERRF_ERRTYPE_LOGGED 

Outputs logs to NAND in some cases.

◆ ERRF_ExceptionType

Types of 'Exceptions' thrown for ERRF_ERRTYPE_EXCEPTION.

Enumerator
ERRF_EXCEPTION_PREFETCH_ABORT 

Prefetch Abort.

ERRF_EXCEPTION_DATA_ABORT 

Data abort.

ERRF_EXCEPTION_UNDEFINED 

Undefined instruction.

ERRF_EXCEPTION_VFP 

VFP (floating point) exception.

Function Documentation

◆ ERRF_ExceptionHandler()

void ERRF_ExceptionHandler ( ERRF_ExceptionInfo excep,
CpuRegisters regs 
)

Handles an exception using ErrDisp.

Parameters
excepException information
regsCPU registers

You might want to clear ENVINFO's bit0 to be able to see any debugging information.

See also
threadOnException

◆ ERRF_Throw()

Result ERRF_Throw ( const ERRF_FatalErrInfo error)

Throws a system error and possibly results in ErrDisp triggering.

Parameters
[in]errorError to throw.

After performing this, the system may panic and need to be rebooted. Extra information will be displayed on the top screen with a developer console or the proper patches in a CFW applied.

The error may not be shown and execution aborted until errfExit(void) is called.

You may wish to use ERRF_ThrowResult() or ERRF_ThrowResultWithMessage() instead of constructing the ERRF_FatalErrInfo struct yourself.

◆ ERRF_ThrowResult()

Result ERRF_ThrowResult ( Result  failure)

Throws a system error with the given Result code.

Parameters
[in]failureResult code to throw.

This calls ERRF_Throw() with error type ERRF_ERRTYPE_GENERIC and fills in the required data.

This function does fill in the address where this function was called from.

See https://3dbrew.org/wiki/ERR:Throw#Generic for expected top screen output on development units/patched ErrDisp.

◆ ERRF_ThrowResultWithMessage()

Result ERRF_ThrowResultWithMessage ( Result  failure,
const char *  message 
)

Throws a system error with the given Result code and message.

Parameters
[in]failureResult code to throw.
[in]messageThe message to display.

This calls ERRF_Throw() with error type ERRF_ERRTYPE_FAILURE and fills in the required data.

This function does not fill in the address where this function was called from because it would not be displayed.

The message is only displayed on development units/patched ErrDisp.

See https://3dbrew.org/wiki/ERR:Throw#Result_Failure for expected top screen output on development units/patched ErrDisp.

◆ errfGetSessionHandle()

Handle* errfGetSessionHandle ( void  )

Gets the current err:f API session handle.

Returns
The current err:f API session handle.