W3cubDocs

/JSDoc

@throws

Table of Contents

Synonyms

@exception

Syntax

  • @throws free-form description
  • @throws {<type>}
  • @throws {<type>} free-form description

Overview

The @throws tag allows you to document an error that a function might throw. You can include the @throws tag more than once in a single JSDoc comment.

Examples

Using the @throws tag with a type
/**
 * @throws {InvalidArgumentException}
 */
function foo(x) {}
Using the @throws tag with a description
/**
 * @throws Will throw an error if the argument is null.
 */
function bar(x) {}
Using the @throws tag with a type and description
/**
 * @throws {DivideByZero} Argument x must be non-zero.
 */
function baz(x) {}

© 2011–2017 the contributors to the JSDoc 3 documentation project
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://usejsdoc.org/tags-throws.html