# Programming Example
## Example Description
The following functions are demonstrated:
1. Registering the hook function for error handling
2. Executing the function for error handling
## Example Code
The code is as follows:
```c
#include "los_err.h"
#include "los_typedef.h"
#include
void Test_ErrHandle(CHAR *fileName, UINT32 lineNo, UINT32 errorNo, UINT32 paraLen, VOID *para)
{
printf("err handle ok\n");
}
static UINT32 TestCase(VOID)
{
UINT32 errNo = 0;
UINT32 ret;
UINT32 errLine = 16;
LOS_RegErrHandle(Test_ErrHandle);
ret = LOS_ErrHandle("os_unspecific_file", errLine, errNo, 0, NULL);
if (ret != LOS_OK) {
return LOS_NOK;
}
return LOS_OK;
}
```
## Verification
The verification result is as follows:
```
Huawei LiteOS # err handle ok
```
## Complete Code
[sample\_err.c](resource/sample_err.c)