简体   繁体   English

我可以在Javadoc中为同一个异常使用多个@throws标记吗?

[英]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? 如果我的应用程序由于多种原因抛出相同的异常,我可以使用多个@throws javadoc标记吗? 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? 是否被JavaDoc标准禁止?

It is valid in java 6,7 and 8. See the docs: 它在java 6,7和8中有效。请参阅文档:

Multiple @throws tags can be used in a given doc comment for the same or different exceptions. 对于相同或不同的异常,可以在给定的doc注释中使用多个@throws标记。

(emph. mine) (我的)

刚测试了这个生成的JavaDoc包含了所有3个@throws。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM