# Script Execution Failure Handling Process

The failure handling process is primarily used to collect failure reasons, system information, etc. for subsequent debugging and analysis, then end the audit process.

## STEP-1 Collect Failure Reasons

Collect error information from the script execution failure.
- If the current error information is too long, it can be output to the `fail.log` file in the output directory
- If the error messages are garbled, first determine the current encoding of the garbled environment, then try switching the encoding to obtain readable error information

## STEP-2 Collect System Information

Execute commands to collect the following information:

- Detailed current system information (OS-Type, system version number)
- Whether bash is available, bash version
- Version of the interpreter that failed to execute the script

## STEP-3 Output Debug Report and Provide Termination Prompt

Briefly analyze possible causes of the failure, output a failure analysis report (`fail_report.md`) to the output directory, then **end the audit process** and prompt the user to contact the provider for assistance.

- If bash is missing, prompt the user to install bash (on Windows, git-bash can be installed) and add bash to PATH, in order to use bash scripts to circumvent the issue
