Finalize the diagnostic engine if an error is thrown #637
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug/issue #, if applicable: rdar://110782381
Summary
If an error is thrown before the documentation converter completes successfully, the diagnostic engine is never finalized. This means that diagnostic consumers that gather and write diagnostic as two separate steps won't write any diagnostics.
This PR changes that so that the diagnostic engine is finalized before the documentation converter returns from
convert(...)
. It also makes the finalization synchronous so that callers can rely on any diagnostics having been written after `convert(...) ends—either successfully or with a thrown error.Dependencies
None
Testing
Run
docc convert
with a--diagnostics-file /path/to/some-file.json
and some content that result in an unexpected error (for example a symbol graph file with relationships but no symbols).After the failed documentation build, the diagnostic file should have been created.
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded