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) {}