Victor L
Victor L

Reputation: 10230

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?

Upvotes: 8

Views: 5579

Answers (2)

Nanne
Nanne

Reputation: 64409

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

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

(emph. mine)

Upvotes: 11

cdc
cdc

Reputation: 2571

Just tested this the generated JavaDoc contains all 3 @throws.

Upvotes: 1

Related Questions