<commit_before>## Introduction
Document captures steps for adding application specific error yaml files

### Write app specific error yaml files
Write error yamls for your application and place them in your application
repository.

Refer to *Host.errors.yaml* at
https://github.com/openbmc/openpower-debug-collector/blob/master/org/open_power/

### Makefile rules to run sdbus++ on error yaml files
Modify the Makefile.am as shown bellow for generation of error.cpp and erorr.hpp
```
org/open_power/Host/error.hpp: ${srcdir}/org/open_power/Host.errors.yaml
    @mkdir -p `dirname $@`
    $(SDBUSPLUSPLUS) -r $(srcdir) error exception-header org.open_power.Host > $@
```
```
org/open_power/Host/error.cpp: ${srcdir}/org/open_power/Host.errors.yaml
    @mkdir -p `dirname $@`
    $(SDBUSPLUSPLUS) -r $(srcdir) error exception-cpp org.open_power.Host > $@
```
### Write native recipe to copy error yaml files
Application specific error yaml files need to be copied to a known location
so that phosphor-logging can generate error metadata by parsing the error
yaml files.

Refer to **do_install_append** method in
**openpower-debug-collector-error-native.bb** at
https://github.com/openbmc/openbmc/blob/master/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/

### Establish dependency with phosphor-logging
Establish debendency with phosphor-logging to ensure that error yaml files are
copied to a known location before phosphor logging parses the error yaml files

Refer to **phosphor-logging-error-logs-native.bbappend** at
https://github.com/openbmc/openbmc/blob/master/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/

###Generate application local elog-errors.hpp file
Applications should be independently compilable so it cannot have a
dependency on the elog-errors.hpp generated by phosphor-logging

Generate application specific elog-errors.hpp using the elog-gen.py
parser. In future the same will be generated through autotools.

The application specific elog-errors.hpp is for the build purpose and the
elog-errors.hpp from phosphor-logging will be used during elog commit/report

#### Example
python tools/elog-gen.py -y /home/OpenBmc/openpower-occ-control/ -u ./tools/ -t
tools/phosphor-logging/templates/ -m elog-gen-template.mako.hpp -o
elog-errors.hpp

### Reporting error
To report (commit) the error follow the below format
***report<sdbusplus::exception_t>(metadata)***
#### *example*
```
#include <xyz/openbmc_project/Software/Version/error.hpp>
#include "elog-errors.hpp" #Use application specific header file
<commit_msg>Grammar fixes in app-local-errors README<commit_after>## Introduction
This document captures steps for adding application specific error yaml files

### Write app specific error yaml files
Write error yamls for your application and place them in your application
repository.

Refer to *Host.errors.yaml* at
https://github.com/openbmc/openpower-debug-collector/blob/master/org/open_power/

### Makefile rules to run sdbus++ on error yaml files
Modify the Makefile.am as shown below for generation of error.cpp and erorr.hpp
```
org/open_power/Host/error.hpp: ${srcdir}/org/open_power/Host.errors.yaml
    @mkdir -p `dirname $@`
    $(SDBUSPLUSPLUS) -r $(srcdir) error exception-header org.open_power.Host > $@
```
```
org/open_power/Host/error.cpp: ${srcdir}/org/open_power/Host.errors.yaml
    @mkdir -p `dirname $@`
    $(SDBUSPLUSPLUS) -r $(srcdir) error exception-cpp org.open_power.Host > $@
```
### Write native recipe to copy error yaml files
Application specific error yaml files need to be copied to a known location
so that phosphor-logging can generate error metadata by parsing the error
yaml files.

Refer to **do_install_append** method in
**openpower-debug-collector-error-native.bb** at
https://github.com/openbmc/openbmc/blob/master/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/

### Establish dependency with phosphor-logging
Establish dependency with phosphor-logging to ensure that error yaml files are
copied to a known location before phosphor logging parses the error yaml files

Refer to **phosphor-logging-error-logs-native.bbappend** at
https://github.com/openbmc/openbmc/blob/master/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/debug/

### Generate application local elog-errors.hpp file
Applications should be independently compilable so it cannot have a
dependency on the elog-errors.hpp generated by phosphor-logging

Generate application specific elog-errors.hpp using the elog-gen.py
parser. In the future, elog-errors.hpp will be generated through autotools.

The application specific elog-errors.hpp is for the build process and the
elog-errors.hpp from phosphor-logging will be used during elog commit/report

#### Example
python tools/elog-gen.py -y /home/OpenBmc/openpower-occ-control/ -u ./tools/ -t
tools/phosphor-logging/templates/ -m elog-gen-template.mako.hpp -o
elog-errors.hpp

### Reporting error
To report (commit) the error follow the below format
***report<sdbusplus::exception_t>(metadata)***
#### *example*
```
#include <xyz/openbmc_project/Software/Version/error.hpp>
#include "elog-errors.hpp" #Use application specific header file

{'fraction_non_alphanumeric': 0.10446325509811466, 'fraction_numerical': 0.0, 'mean_word_length': 4.861330326944757, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3595364', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1532, 'n_words': 503}