summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit/error_test.ts1
-rw-r--r--cli/tsc/dts/lib.deno.ns.d.ts12
-rw-r--r--core/error_codes.rs1
-rw-r--r--runtime/errors.rs2
-rw-r--r--runtime/js/01_errors.js8
-rw-r--r--runtime/js/99_main.js1
6 files changed, 21 insertions, 4 deletions
diff --git a/cli/tests/unit/error_test.ts b/cli/tests/unit/error_test.ts
index bb7a9baf8..6fdf4f762 100644
--- a/cli/tests/unit/error_test.ts
+++ b/cli/tests/unit/error_test.ts
@@ -15,6 +15,7 @@ Deno.test("Errors work", () => {
assert(new Deno.errors.InvalidData("msg") instanceof Error);
assert(new Deno.errors.TimedOut("msg") instanceof Error);
assert(new Deno.errors.Interrupted("msg") instanceof Error);
+ assert(new Deno.errors.WouldBlock("msg") instanceof Error);
assert(new Deno.errors.WriteZero("msg") instanceof Error);
assert(new Deno.errors.UnexpectedEof("msg") instanceof Error);
assert(new Deno.errors.BadResource("msg") instanceof Error);
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts
index 33a568b65..d81e4afcd 100644
--- a/cli/tsc/dts/lib.deno.ns.d.ts
+++ b/cli/tsc/dts/lib.deno.ns.d.ts
@@ -220,6 +220,12 @@ declare namespace Deno {
* @category Errors */
export class Interrupted extends Error {}
/**
+ * Raised when the underlying operating system would need to block to
+ * complete but an asynchronous (non-blocking) API is used.
+ *
+ * @category Errors */
+ export class WouldBlock extends Error {}
+ /**
* Raised when expecting to write to a IO buffer resulted in zero bytes
* being written.
*
@@ -4377,7 +4383,7 @@ declare namespace Deno {
* const status = await Deno.permissions.query({ name: "read", path: "/etc" });
* console.log(status.state);
* ```
- *
+ *
* ```ts
* const status = Deno.permissions.querySync({ name: "read", path: "/etc" });
* console.log(status.state);
@@ -4391,7 +4397,7 @@ declare namespace Deno {
* const status = await Deno.permissions.revoke({ name: "run" });
* assert(status.state !== "granted")
* ```
- *
+ *
* ```ts
* import { assert } from "https://deno.land/std/testing/asserts.ts";
*
@@ -4409,7 +4415,7 @@ declare namespace Deno {
* console.log("'env' permission is denied.");
* }
* ```
- *
+ *
* ```ts
* const status = Deno.permissions.requestSync({ name: "env" });
* if (status.state === "granted") {
diff --git a/core/error_codes.rs b/core/error_codes.rs
index 874aa4ec6..ebe036609 100644
--- a/core/error_codes.rs
+++ b/core/error_codes.rs
@@ -56,6 +56,7 @@ fn get_io_error_code(err: &std::io::Error) -> &'static str {
// ErrorKind::ExecutableFileBusy => "ETXTBSY",
// ErrorKind::CrossesDevices => "EXDEV",
ErrorKind::PermissionDenied => "EACCES", // NOTE: Collides with EPERM ...
+ ErrorKind::WouldBlock => "EWOULDBLOCK", // NOTE: Collides with EAGAIN ...
_ => "",
}
}
diff --git a/runtime/errors.rs b/runtime/errors.rs
index 68fae9387..b26fd9fe3 100644
--- a/runtime/errors.rs
+++ b/runtime/errors.rs
@@ -58,7 +58,7 @@ fn get_io_error_class(error: &io::Error) -> &'static str {
WriteZero => "WriteZero",
UnexpectedEof => "UnexpectedEof",
Other => "Error",
- WouldBlock => unreachable!(),
+ WouldBlock => "WouldBlock",
// Non-exhaustive enum - might add new variants
// in the future
_ => "Error",
diff --git a/runtime/js/01_errors.js b/runtime/js/01_errors.js
index 7e2ad29ab..8288e3ce9 100644
--- a/runtime/js/01_errors.js
+++ b/runtime/js/01_errors.js
@@ -96,6 +96,13 @@ class WriteZero extends Error {
}
}
+class WouldBlock extends Error {
+ constructor(msg) {
+ super(msg);
+ this.name = "WouldBlock";
+ }
+}
+
class UnexpectedEof extends Error {
constructor(msg) {
super(msg);
@@ -139,6 +146,7 @@ const errors = {
TimedOut,
Interrupted,
WriteZero,
+ WouldBlock,
UnexpectedEof,
BadResource,
Http,
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index fd7b93e24..a4301ed3a 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -265,6 +265,7 @@ function registerErrors() {
core.registerErrorClass("InvalidData", errors.InvalidData);
core.registerErrorClass("TimedOut", errors.TimedOut);
core.registerErrorClass("Interrupted", errors.Interrupted);
+ core.registerErrorClass("WouldBlock", errors.WouldBlock);
core.registerErrorClass("WriteZero", errors.WriteZero);
core.registerErrorClass("UnexpectedEof", errors.UnexpectedEof);
core.registerErrorClass("BadResource", errors.BadResource);