summaryrefslogtreecommitdiff
path: root/runtime/errors.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-06-29 01:46:16 +0200
committerGitHub <noreply@github.com>2023-06-29 01:46:16 +0200
commit0434e041778cb3803de901b841f18b8fd8cc2a67 (patch)
tree0c89ce9c09e8a53c20fef5a5053ffdd4af382400 /runtime/errors.rs
parent673cdd714921124fae8ecd3c3a405e37a8ece404 (diff)
feat: add more Deno.errors classes (#19514)
This commit adds following new error classes: - `Deno.errors.NotADirectory` - `Deno.errors.FilesystemLoop` - `Deno.errors.IsADirectory` - `Deno.errors.NetworkUnreachable` Closes https://github.com/denoland/deno/issues/19408
Diffstat (limited to 'runtime/errors.rs')
-rw-r--r--runtime/errors.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/runtime/errors.rs b/runtime/errors.rs
index 5618c07ed..e6ae14abb 100644
--- a/runtime/errors.rs
+++ b/runtime/errors.rs
@@ -61,7 +61,16 @@ fn get_io_error_class(error: &io::Error) -> &'static str {
WouldBlock => "WouldBlock",
// Non-exhaustive enum - might add new variants
// in the future
- _ => "Error",
+ kind => {
+ let kind_str = kind.to_string();
+ match kind_str.as_str() {
+ "FilesystemLoop" => "FilesystemLoop",
+ "IsADirectory" => "IsADirectory",
+ "NetworkUnreachable" => "NetworkUnreachable",
+ "NotADirectory" => "NotADirectory",
+ _ => "Error",
+ }
+ }
}
}
@@ -146,6 +155,10 @@ pub fn get_nix_error_class(error: &nix::Error) -> &'static str {
nix::Error::ENOTTY => "BadResource",
nix::Error::EPERM => "PermissionDenied",
nix::Error::ESRCH => "NotFound",
+ nix::Error::ELOOP => "FilesystemLoop",
+ nix::Error::ENOTDIR => "NotADirectory",
+ nix::Error::ENETUNREACH => "NetworkUnreachable",
+ nix::Error::EISDIR => "IsADirectory",
nix::Error::UnknownErrno => "Error",
&nix::Error::ENOTSUP => unreachable!(),
_ => "Error",