9

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
john
  • 11,311
  • 40
  • 131
  • 251
  • 3
    Yes, you need 2 `@throws` tags. Similar to how you need 2 `@param` tags if your method has 2 parameters – Vince Apr 18 '15 at 18:07

1 Answers1

19

You cannot specify 2 exceptions with 1 @throws tag


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

Vince
  • 14,470
  • 7
  • 39
  • 84