diff options
author | Ian Bull <irbull@eclipsesource.com> | 2024-08-28 16:40:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-28 22:40:37 +0200 |
commit | 6ccaebcdeae95a82b270ac5bde78b65b37fadb45 (patch) | |
tree | 4c50dc3aa74ef6bef2aca4706af8b16213b1e1f2 /ext/http | |
parent | 231bdc0aa0c08914735001f5e1261e1808d68190 (diff) |
refactor(ext): throw new error instead of throw error (#25272)
To ensure consistency across the codebase, this commit refactors the
code in the `ext` folder to use `throw new Error`` instead of `throw`
for throwing errors.
Fixes https://github.com/denoland/deno/issues/25270
Diffstat (limited to 'ext/http')
-rw-r--r-- | ext/http/00_serve.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/http/00_serve.ts b/ext/http/00_serve.ts index 02910d580..c8f4e0604 100644 --- a/ext/http/00_serve.ts +++ b/ext/http/00_serve.ts @@ -457,7 +457,7 @@ function fastSyncResponseOrStream( // At this point in the response it needs to be a stream if (!ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, stream)) { innerRequest?.close(); - throw TypeError("invalid response"); + throw new TypeError("invalid response"); } const resourceBacking = getReadableStreamResourceBacking(stream); let rid, autoClose; @@ -506,13 +506,13 @@ function mapToCallback(context, callback, onError) { // Throwing Error if the handler return value is not a Response class if (!ObjectPrototypeIsPrototypeOf(ResponsePrototype, response)) { - throw TypeError( + throw new TypeError( "Return value from serve handler must be a response or a promise resolving to a response", ); } if (response.bodyUsed) { - throw TypeError( + throw new TypeError( "The body of the Response returned from the serve handler has already been consumed.", ); } @@ -520,7 +520,7 @@ function mapToCallback(context, callback, onError) { try { response = await onError(error); if (!ObjectPrototypeIsPrototypeOf(ResponsePrototype, response)) { - throw TypeError( + throw new TypeError( "Return value from onError handler must be a response or a promise resolving to a response", ); } |