加载中...

@throws


描述: 说明可能会被抛出什么样的错误。

别名:

  • exception

语法

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

Overview

@throws标签可以让你描述函数可能会抛出的错误。在一个JSDoc注释块中您可以包含多个@throws标签。

例子

例如,在type中使用@throws标签:

  1. /**
  2. * @throws {InvalidArgumentException}
  3. */
  4. function foo(x) {}

例如,在描述中使用@throws标签:

  1. /**
  2. * @throws Will throw an error if the argument is null.
  3. */
  4. function bar(x) {}

例如,在type和描述中使用@throws标签:

  1. /**
  2. * @throws {DivideByZero} Argument x must be non-zero.
  3. */
  4. function baz(x) {}

还没有评论.