Rush Stack商店博客活动
跳到主要内容

@throws

标准化扩展
语法种类块标签

用法

用于记录函数或属性可能抛出的异常类型。

应使用单独的 @throws 块来记录每种异常类型。此标签仅供参考,并不限制抛出其他类型。建议(但非必需)@throws 块以仅包含异常名称的行开头。

例如

/**
* Retrieves metadata about a book from the catalog.
*
* @param isbnCode - the ISBN number for the book
* @returns the retrieved book object
*
* @throws {@link IsbnSyntaxError}
* This exception is thrown if the input is not a valid ISBN number.
*
* @throws {@link book-lib#BookNotFoundError}
* Thrown if the ISBN number is valid, but no such book exists in the catalog.
*
* @public
*/
function fetchBookByIsbn(isbnCode: string): Book;

另请参阅

  • RFC 171: 用于记录异常的 @throws 标签