From 3134abefa462ead8bb8e2e4aa8a5b57910f3d430 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Fri, 27 Sep 2024 16:07:20 +0200 Subject: BREAKING(ext/net): improved error code accuracy (#25383) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartek IwaƄczuk --- runtime/ops/http.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'runtime/ops') diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs index a195a759e..cec8b0ef8 100644 --- a/runtime/ops/http.rs +++ b/runtime/ops/http.rs @@ -2,8 +2,8 @@ use std::rc::Rc; -use deno_core::error::bad_resource; use deno_core::error::bad_resource_id; +use deno_core::error::custom_error; use deno_core::error::AnyError; use deno_core::op2; use deno_core::OpState; @@ -27,10 +27,10 @@ fn op_http_start( .take::(tcp_stream_rid) { // This TCP connection might be used somewhere else. If it's the case, we cannot proceed with the - // process of starting a HTTP server on top of this TCP connection, so we just return a bad - // resource error. See also: https://github.com/denoland/deno/pull/16242 + // process of starting a HTTP server on top of this TCP connection, so we just return a Busy error. + // See also: https://github.com/denoland/deno/pull/16242 let resource = Rc::try_unwrap(resource_rc) - .map_err(|_| bad_resource("TCP stream is currently in use"))?; + .map_err(|_| custom_error("Busy", "TCP stream is currently in use"))?; let (read_half, write_half) = resource.into_inner(); let tcp_stream = read_half.reunite(write_half)?; let addr = tcp_stream.local_addr()?; @@ -42,10 +42,10 @@ fn op_http_start( .take::(tcp_stream_rid) { // This TLS connection might be used somewhere else. If it's the case, we cannot proceed with the - // process of starting a HTTP server on top of this TLS connection, so we just return a bad - // resource error. See also: https://github.com/denoland/deno/pull/16242 + // process of starting a HTTP server on top of this TLS connection, so we just return a Busy error. + // See also: https://github.com/denoland/deno/pull/16242 let resource = Rc::try_unwrap(resource_rc) - .map_err(|_| bad_resource("TLS stream is currently in use"))?; + .map_err(|_| custom_error("Busy", "TLS stream is currently in use"))?; let (read_half, write_half) = resource.into_inner(); let tls_stream = read_half.unsplit(write_half); let addr = tls_stream.local_addr()?; @@ -58,10 +58,10 @@ fn op_http_start( .take::(tcp_stream_rid) { // This UNIX socket might be used somewhere else. If it's the case, we cannot proceed with the - // process of starting a HTTP server on top of this UNIX socket, so we just return a bad - // resource error. See also: https://github.com/denoland/deno/pull/16242 + // process of starting a HTTP server on top of this UNIX socket, so we just return a Busy error. + // See also: https://github.com/denoland/deno/pull/16242 let resource = Rc::try_unwrap(resource_rc) - .map_err(|_| bad_resource("UNIX stream is currently in use"))?; + .map_err(|_| custom_error("Busy", "Unix socket is currently in use"))?; let (read_half, write_half) = resource.into_inner(); let unix_stream = read_half.reunite(write_half)?; let addr = unix_stream.local_addr()?; -- cgit v1.2.3