1

According to the documentation of YUIdoc (which seems to be in this case equivalent to jsdoc) there is a @throws tag to document a potentially thrown error.

Specifies an error which method throws. A @throws tag has the structure @throws {type} description. The {type} is optional.

In my case there are several checks in a function which can throw an error so I would like to list them with @throws. But you can not have more than one @throws tag. So how can I put a list of potentially thrown errors in this tag?

Michael Hoeller
  • 22,018
  • 10
  • 39
  • 66

2 Answers2

6

I know it is old. But as this is the first google result but does not have a proper answer I will show you the solution I found here: https://stackoverflow.com/a/29720979/8466273

Just use multiple @throws:

/**
 * -- other definitions --
 * @throws {RangeError}   must be in range 0 to 10
 * @throws {URIError}     wrong URI given
 * -- other definitions --
 */
  • Documentation: https://jsdoc.app/tags-throws.html `"You can include the @throws tag more than once in a single JSDoc comment."` – jave.web Aug 20 '22 at 11:19
2

Finally I can answer the question myself:

Just make it a list. If you like you can change the look of the text via style tag - just add it to the <ul>

 * @throws {}
 * <ul >
 * <li> {exception}  Condition 1</li>
 * <li> {exception}  Condition 2/li>
 * <li> {exception}  Condition 3</li>
 * </ul> 
Michael Hoeller
  • 22,018
  • 10
  • 39
  • 66