1. A method for controlling a hardware circuit with a processor, the processor used for executing a code to control the hardware circuit, the code comprising: a plurality of lower-level subroutines, wherein after the processor executes various lower-level subroutines, the hardware circuit will be controlled to execute various corresponding operations, and each lower-level subroutine will record results, which come from the hardware circuit executing the corresponding operations, in an error code; wherein each result corresponds to a recovery operation; a plurality of higher-level subroutines, each higher-level subroutines used for calling at least a lower-level subroutine to control the hardware circuit to execute operations corresponding to the lower-level subroutine according to the called lower-level subroutine when the processor executesthe higher-level subroutine; a plurality of recovery subroutines, each recovery subroutine corresponding to a recovery operations for controlling the hardware circuit to execute various corresponding recovery operations, after the processor executes various recovery subroutines; and an error-handling subroutine for calling the recovery subroutines according to the error code; the method comprising: after the processor executes the higher-level subroutines, executing the error-handling subroutine to allow the processor to control the hardware circuit to executethe corresponding recovery operations according to the results corresponding to the lower-level subroutines.