Skip to content

Commit

Permalink
Fix type issue in optionsFromArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleJune committed Oct 17, 2021
1 parent bb1f1e7 commit f30ec4b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@ export interface HttpErrorInit extends ErrorInit {
expose?: boolean;
}

function errorNameForStatus(status: number): string {
let name: string;
if (STATUS_TEXT.has(status)) {
name = status === Status.Teapot
? "Teapot"
: STATUS_TEXT.get(status)!.replace(/\W/g, "");
if (status !== Status.InternalServerError) name += "Error";
} else {
name = `Unknown${status < 500 ? "Client" : "Server"}Error`;
}
return name;
}

/**
* Converts HttpError arguments to an options object.
* Prioritizing status and message arguments over status and message options.
Expand Down Expand Up @@ -60,7 +47,20 @@ export function optionsFromArgs<Init extends HttpErrorInit = HttpErrorInit>(
message = init?.message;
}

return { ...init, status, message };
return { ...init, status, message } as Init;
}

function errorNameForStatus(status: number): string {
let name: string;
if (STATUS_TEXT.has(status)) {
name = status === Status.Teapot
? "Teapot"
: STATUS_TEXT.get(status)!.replace(/\W/g, "");
if (status !== Status.InternalServerError) name += "Error";
} else {
name = `Unknown${status < 500 ? "Client" : "Server"}Error`;
}
return name;
}

/** An error for an HTTP request. */
Expand Down

0 comments on commit f30ec4b

Please sign in to comment.