Skip to content

Commit

Permalink
Merge pull request #29 from pihart/jsdoc-throws
Browse files Browse the repository at this point in the history
Use JSDoc syntax for @throws annotations (when applicable)
  • Loading branch information
pihart authored Mar 23, 2021
2 parents 9b5928b + 481ce05 commit c121716
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/lib/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { CustomError } from "./error";
export class AssertionError extends CustomError {}

/**
* Asserts `bool`
* @throws `errorConstructor`
* Asserts {@param bool}
* @param errorConstructor A constructor for the thrown error class
* @throws {@param errorConstructor}
*/
export function Assert(
bool: boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export namespace Email {

/**
* Assert using RFC 5322 email validation
* @throws {@linkcode InvalidEmailException}
* @throws {InvalidEmailException} If {@param str} is not a syntactically valid email
* @warn Not restrictive; see {@linkcode roughValidate}
*/
export const roughAssert = (str: string): asserts str is Email => {
Expand Down
14 changes: 6 additions & 8 deletions src/lib/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ export class Network {
*
* @param filePath The network URL of file to be fetched
* @return The resource as parsed JSON object
* @throws
* [[`ResourceNotFoundException`]] if the request fails,
* defined by the status being in [200, 300)
* @throws {ResourceNotFoundException} if the request fails,
* defined by the status not being in [200, 300)
* @warn Doesn't implement timeout logic
* @deprecated
*/
Expand All @@ -78,9 +77,8 @@ export class Network {
* @return
* The XHR as a Promise,
* with a [[`ResourceNotFoundException`]] in case of rejection
* @throws
* [[`ResourceNotFoundException`]] if the request fails,
* as defined by {@param resolveCondition}
* @throws {ResourceNotFoundException} if the request fails,
* as defined by the negation of {@param resolveCondition}
* @warn Doesn't implement timeout logic
* @deprecated
*/
Expand Down Expand Up @@ -115,7 +113,7 @@ export class Network {
* Use instead of `window.fetch` because it rejects failed transactions.
*
* @return The result of the request to the resource, parsed as JSON, if it is `ok`
* @throws [[`ResourceNotFoundException`]] if not `ok`
* @throws {ResourceNotFoundException} if not `ok`
*/
static async loadJSON(input: RequestInfo, init?: RequestInit): Promise<any> {
const response = await Network.fetch(input, init);
Expand All @@ -128,7 +126,7 @@ export class Network {
* Use instead of `window.fetch` because it rejects failed transactions.
*
* @return The result of `window.fetch`, if it is `ok`
* @throws [[`ResourceNotFoundException`]] if not `ok`
* @throws {ResourceNotFoundException} if not `ok`
*/
static async fetch(
input: RequestInfo,
Expand Down

0 comments on commit c121716

Please sign in to comment.