From 6ccaebcdeae95a82b270ac5bde78b65b37fadb45 Mon Sep 17 00:00:00 2001 From: Ian Bull Date: Wed, 28 Aug 2024 16:40:37 -0400 Subject: 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 --- ext/http/00_serve.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ext/http/00_serve.ts') 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", ); } -- cgit v1.2.3