libctru  v2.4.1
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_NAND_DAMAGED = 1 ,
  ERRF_ERRTYPE_CARD_REMOVED = 2 ,
  ERRF_ERRTYPE_EXCEPTION = 3 ,
  ERRF_ERRTYPE_FAILURE = 4 ,
  ERRF_ERRTYPE_LOG_ONLY = 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 logs it. More...
 
Result ERRF_ThrowResult (Result failure)
 Throws (and logs) a system error with the given Result code. More...
 
Result ERRF_LogResult (Result failure)
 Logs 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...
 
Result ERRF_SetUserString (const char *user_string)
 Specify an additional user string to use for error reporting. 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 

Generic fatal error. Shows miscellaneous info, including the address of the caller.

ERRF_ERRTYPE_NAND_DAMAGED 

Damaged NAND (CC_ERROR after reading CSR)

ERRF_ERRTYPE_CARD_REMOVED 

Game content storage medium (cartridge and/or SD card) ejected. Not logged.

ERRF_ERRTYPE_EXCEPTION 

CPU or VFP exception.

ERRF_ERRTYPE_FAILURE 

Fatal error with a message instead of the caller's address.

ERRF_ERRTYPE_LOG_ONLY 

Log-level failure. Does not display the exception and does not force the system to reboot.

◆ 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_LogResult()

Result ERRF_LogResult ( Result  failure)

Logs a system error with the given Result code.

Parameters
[in]failureResult code to log.

Similar to ERRF_Throw, except that it does not display anything on the screen, nor does it force the system to reboot.

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

◆ ERRF_SetUserString()

Result ERRF_SetUserString ( const char *  user_string)

Specify an additional user string to use for error reporting.

Parameters
[in]user_stringUser string (up to 256 bytes, not including NUL byte)

◆ ERRF_Throw()

Result ERRF_Throw ( const ERRF_FatalErrInfo error)

Throws a system error and possibly logs it.

Parameters
[in]errorError to throw.

ErrDisp may convert the error info to ERRF_ERRTYPE_NAND_DAMAGED or ERRF_ERRTYPE_CARD_REMOVED depending on the error code.

Except with ERRF_ERRTYPE_LOG_ONLY, the system will panic and will need to be rebooted. Fatal error information will also be logged into a file, unless the type either ERRF_ERRTYPE_NAND_DAMAGED or ERRF_ERRTYPE_CARD_REMOVED.

No error will be shown if the system is asleep.

On retail units with vanilla firmware, no detailed information will be displayed on screen.

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 (and logs) 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.

◆ 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.

◆ errfGetSessionHandle()

Handle* errfGetSessionHandle ( void  )

Gets the current err:f API session handle.

Returns
The current err:f API session handle.