Skip to content

Documentation Comments Style Guide - @throws #19923

@gianmarcoschifone

Description

@gianmarcoschifone

Parent issue: #19807

Coverage table

Chapter link

Content

Image

Image

Text

@throws (@exception was the original tag) (reference page)

A @throws tag should be included for any checked exceptions (declared in the throws clause), as illustrated below, and also for any unchecked exceptions that the caller might reasonably want to catch, with the exception of NullPointerException. Errors should not be documented as they are unpredictable. For more details, please see Documenting Exceptions with the @throws Tag.

/**
* @throws IOException  If an input or output 
*                      exception occurred
*/
public void f() throws IOException {
// body
}

See the Exceptions chapter of the Java Language Specification, Second Edition for more on exceptions. Also see order of multiple @throws tags.

Guidelines

A @throws tag should be included for any checked exceptions (declared in the throws clause)

This chapter is covered by JavadocMethod, using its property validateThrows. Proposal:

Documentation Comments Rule Checkstyle Checks Used Sample files
@throws ✅JavadocMethod
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions