This issue can be reproduced by first creating a report that returns an error. Include this report in an HTML document and run the latter. The document returns an error, but the error code is not recorded in the EXECERRORCODE column of the IS_DOCUMENT_STATS table. Instead, a value of '0' is recorded in this column.
On the other hand, if the same report is included in a Report Writing document (also known as a Report Services document), the error code (for example, -2147466604) is recorded in the EXECERRORCODE column of the IS_DOCUMENT_STATS table.
This behavior is by design. An HTML document only combines the results from all of its children reports while a Report Services document processes the data from all of its children reports. For example, suppose an HTML document has two reports in it, such as R1 and R2. If R1 errors out and R2 succeeds, it can still combine the results from the two reports and complete execution of the document. The final document displays the results of R2 and displays an error message for R1, but the document itself successfully completes execution. Therefore, this is not considered a failure at the document level; hence, the EXECERRORCODE column is not populated with the error code.
However, in the case of Report Services documents, since data is processed from its children reports, if R1 errors out, the execution of the document itself fails displaying the error message of R1.