Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use multiple @throws tags for the same exception in Javadoc?

Can I use multiple @throws javadoc tags if my application throws the same exception for multiple reasons? For example:

@throws UserException if issue 1 happened
@throws UserException if issue 2 happened
@throws UserException if issue 3 happened

Is it prohibited by JavaDoc standard?

like image 357
Victor Lyuboslavsky Avatar asked Feb 10 '12 15:02

Victor Lyuboslavsky


People also ask

What are Javadoc tags?

The javadoc TagsRepresents the relative path to the generated document's root directory from any generated page. Adds a comment indicating that this API should no longer be used. Adds a Throws subheading to the generated documentation, with the classname and description text.

How do you add a Javadoc to a method?

Place the caret at the declaration in the editor, press Alt+Enter , and select Add Javadoc from the list.


1 Answers

It is valid in java 6,7 and 8. See the docs:

  • Javadoc 6
  • Javadoc 7
  • Javadoc 8

Multiple @throws tags can be used in a given doc comment for the same or different exceptions.

(emph. mine)

like image 109
Nanne Avatar answered Sep 21 '22 12:09

Nanne