JSDoc 中文网

Synonyms

语法

¥Syntax

概述

¥Overview

@throws 标签允许你记录函数可能抛出的错误。你可以在单个 JSDoc 注释中多次包含 @throws 标记。

¥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

将 @throws 标签与类型一起使用
/**

 * @throws {InvalidArgumentException}
 */
function foo(x) {}
使用带有描述的@throws 标签
/**

 * @throws Will throw an error if the argument is null.
 */
function bar(x) {}
使用带有类型和描述的 @throws 标签
/**

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