| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Modules | Data Structures | Macros | Functions
Common application error handler
SDK common libraries

Common application error handler and macros for utilizing a common error handler. More...

## Modules
| Fault ID types

## Data Structures
struct | error_info_t
| Structure containing info about an error of the type NRF_FAULT_ID_SDK_ERROR. More...
struct | assert_info_t
| Structure containing info about an error of the type NRF_FAULT_ID_SDK_ASSERT. More...

## Macros
#define | NRF_FAULT_ID_SDK_RANGE_START 0x00004000
#define | APP_ERROR_HANDLER(ERR_CODE)
| Macro for calling error handler function. More...
#define | APP_ERROR_CHECK(ERR_CODE)
| Macro for calling error handler function if supplied error code any other than NRF_SUCCESS. More...
#define | APP_ERROR_CHECK_BOOL(BOOLEAN_VALUE)
| Macro for calling error handler function if supplied boolean value is false. More...

## Functions
void | app_error_handler (uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name)
| Function for error handling, which is called when an error has occurred. More...
void | app_error_handler_bare (ret_code_t error_code)
| Function for error handling, which is called when an error has occurred. More...
void | app_error_save_and_stop (uint32_t id, uint32_t pc, uint32_t info)
| Function for saving the parameters and entering an eternal loop, for debug purposes. More...
static __INLINE void | app_error_log (uint32_t id, uint32_t pc, uint32_t info)
| Function for printing all error info (using nrf_log). More...
static __INLINE void | app_error_print (uint32_t id, uint32_t pc, uint32_t info)
| Function for printing all error info (using printf). More...
void | app_error_fault_handler (uint32_t id, uint32_t pc, uint32_t info)
| Callback function for errors, asserts, and faults. More...

## Detailed Description

Common application error handler and macros for utilizing a common error handler.

Common application error handler.

## Macro Definition Documentation

#define APP_ERROR_CHECK | ( |  | ERR_CODE | ) |

Value:
do \
{ \
const uint32_t LOCAL_ERR_CODE = (ERR_CODE); \
if (LOCAL_ERR_CODE != NRF_SUCCESS) \
{ \
APP_ERROR_HANDLER(LOCAL_ERR_CODE); \
} \
} while (0)

Macro for calling error handler function if supplied error code any other than NRF_SUCCESS.

Parameters

  [in] | ERR_CODE | Error code supplied to the error handler.

#define APP_ERROR_CHECK_BOOL | ( |  | BOOLEAN_VALUE | ) |

Value:
do \
{ \
const uint32_t LOCAL_BOOLEAN_VALUE = (BOOLEAN_VALUE); \
if (!LOCAL_BOOLEAN_VALUE) \
{ \
APP_ERROR_HANDLER(0); \
} \
} while (0)

Macro for calling error handler function if supplied boolean value is false.

Parameters

  [in] | BOOLEAN_VALUE | Boolean value to be evaluated.

#define APP_ERROR_HANDLER | ( |  | ERR_CODE | ) |

Value:
do \
{ \
app_error_handler_bare((ERR_CODE)); \
} while (0)

Macro for calling error handler function.

Parameters

  [in] | ERR_CODE | Error code supplied to the error handler.

#define NRF_FAULT_ID_SDK_RANGE_START 0x00004000

The start of the range of error IDs defined in the SDK.

## Function Documentation

void app_error_fault_handler | ( | uint32_t | id,
|  | uint32_t | pc,
|  | uint32_t | info
| ) |  |

Callback function for errors, asserts, and faults.

This function is called every time an error is raised in app_error, nrf_assert, or in the SoftDevice. Information about the error can be found in the `info` parameter.

See also nrf_fault_handler_t for more details.

Note
  The function is implemented as weak so that it can be redefined by a custom error handler when needed.

Parameters

  [in] | id | Fault identifier. See Fault ID types.
  [in] | pc | The program counter of the instruction that triggered the fault, or 0 if unavailable.
  [in] | info | Optional additional information regarding the fault. The value of the `id` parameter dictates how to interpret this parameter. Refer to the documentation for each fault identifier (Fault ID types and Fault ID types) for details about interpreting `info`.

void app_error_handler | ( | uint32_t | error_code,
|  | uint32_t | line_num,
|  | const uint8_t * | p_file_name
| ) |  |

Function for error handling, which is called when an error has occurred.

Parameters

  [in] | error_code | Error code supplied to the handler.
  [in] | line_num | Line number where the handler is called.
  [in] | p_file_name | Pointer to the file name.

void app_error_handler_bare | ( | ret_code_t | error_code | ) |

Function for error handling, which is called when an error has occurred.

Parameters

  [in] | error_code | Error code supplied to the handler.

static __INLINE void app_error_log | ( | uint32_t | id,
|  | uint32_t | pc,
|  | uint32_t | info
| ) |  |
| static

Function for printing all error info (using nrf_log).

Nrf_log library must be initialized using NRF_LOG_INIT macro before calling this function.

Parameters

  [in] | id | Fault identifier. See Fault ID types.
  [in] | pc | The program counter of the instruction that triggered the fault, or 0 if unavailable.
  [in] | info | Optional additional information regarding the fault. Refer to each fault identifier for details.

< The start of the range of error IDs defined in the SDK.

< An error stemming from a call to ASSERT (nrf_assert.h). The info parameter is a pointer to an assert_info_t variable.

< The start of the range of error IDs defined in the SDK.

< An error stemming from a call to APP_ERROR_CHECK or APP_ERROR_CHECK_BOOL. The info parameter is a pointer to an error_info_t variable.

static __INLINE void app_error_print | ( | uint32_t | id,
|  | uint32_t | pc,
|  | uint32_t | info
| ) |  |
| static

Function for printing all error info (using printf).

Parameters

  [in] | id | Fault identifier. See Fault ID types.
  [in] | pc | The program counter of the instruction that triggered the fault, or 0 if unavailable.
  [in] | info | Optional additional information regarding the fault. Refer to each fault identifier for details.

< The start of the range of error IDs defined in the SDK.

< An error stemming from a call to ASSERT (nrf_assert.h). The info parameter is a pointer to an assert_info_t variable.

< The start of the range of error IDs defined in the SDK.

< An error stemming from a call to APP_ERROR_CHECK or APP_ERROR_CHECK_BOOL. The info parameter is a pointer to an error_info_t variable.

void app_error_save_and_stop | ( | uint32_t | id,
|  | uint32_t | pc,
|  | uint32_t | info
| ) |  |

Function for saving the parameters and entering an eternal loop, for debug purposes.

Parameters

  [in] | id | Fault identifier. See Fault ID types.
  [in] | pc | The program counter of the instruction that triggered the fault, or 0 if unavailable.
  [in] | info | Optional additional information regarding the fault. Refer to each fault identifier for details.