diff options
author | Luca Casonato <hello@lcas.dev> | 2024-09-27 16:07:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-27 14:07:20 +0000 |
commit | 3134abefa462ead8bb8e2e4aa8a5b57910f3d430 (patch) | |
tree | 0f01cca8ca91ea6fb06347f17a77091259749c28 /runtime/ops/http.rs | |
parent | 88a4f8dd97704b8905d05def949b137a75286b18 (diff) |
BREAKING(ext/net): improved error code accuracy (#25383)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'runtime/ops/http.rs')
-rw-r--r-- | runtime/ops/http.rs | 20 |
1 files changed, 10 insertions, 10 deletions
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::<TcpStreamResource>(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::<TlsStreamResource>(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::<deno_net::io::UnixStreamResource>(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()?; |