RFR: 8287397 : Print top-level exception when snippet fails to read file

Anthony Vanelverdinghe duke at openjdk.org
Sat Nov 12 14:02:34 UTC 2022


On Thu, 26 May 2022 23:29:59 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> When using a snippet as follows (on Windows): `{@snippet file=baz\Baz.java }`, javadoc prints the error:
>> 
>> src\foo\foo\Foo.java:14: error: Error reading file: baz\Baz.java
>> {@snippet file=baz\Baz.java }
>>           ^
>>         (null)
>> 
>> 
>> which is unhelpful. So rather than printing the exception's cause (which is `null` in the example above), it seems better to print the top-level exception itself.
>> 
>> PS: I'll need help from someone to create a JBS issue & sponsor this PR
>
> @anthonyvdotbe You need to change the PR summary by inserting `8287397` (the JBS issue number) at the beginning.
> 
>    8287397 : Print top-level exception when snippet fails to read file

Thanks for your help @jonathan-gibbons

Actually there's several ways to fix the issue:
1. report the top-level exception (simplest, current PR)
2. report the direct cause if non-null, else report the top-level exception (most compatible with current code)
3. report the innermost exception for which `getCause()` is null (most helpful message for the user?)

Which of these do you prefer?

-------------

PR: https://git.openjdk.org/jdk/pull/8826


More information about the javadoc-dev mailing list