本文介绍了如何在单个throw java docs标记中出现多个异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在代码中添加JavaDoc.我需要在一次抛出中添加多个异常.当我在下面添加时,它只能识别NullPointerException,而不能识别IllegalArgumentException.当我将鼠标放在方法上时,有什么方法可以在单个throw标签中提供多个异常,以便它可以识别这两个异常?

I am trying to add a JavaDoc in my code. I need to add multiple exception in a single throw. When I add below, it only recognizes NullPointerException not the IllegalArgumentException. Is there any way to provide multiple exception in a single throw tag so that it can recognize both, when I place my mouse on the method?

@throws NullPointerException, IllegalArgumentException when invalid userId, timeout is passed

还是我需要这样做?因此,我要重复两次相同的评论.

Or I need to do it like this? By this, I am repeating same comment twice.

@throws NullPointerException when invalid userId, timeout is passed
@throws IllegalArgumentException when invalid userId, timeout is passed

推荐答案

您不能使用1个@throws标记指定2个异常

You cannot specify 2 exceptions with 1 @throws tag

对于每个异常,您都需要一个@throws标记.这样您就可以对抛出的每个异常进行描述.

You need a @throws tag for each exception you have. This allows you to give a description for each exception you are throwing.

这篇关于如何在单个throw java docs标记中出现多个异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 04:18