summaryrefslogtreecommitdiff
path: root/core/ops_builtin.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2021-11-16 09:02:28 -0500
committerGitHub <noreply@github.com>2021-11-16 09:02:28 -0500
commitb2036a4db71afd67a78f932528143fb07faea538 (patch)
treea78612e8868609af7aa6fe9ecf49d3ab0c42c9da /core/ops_builtin.rs
parentf9f9ddc5e308809343bbf5c07d4487df5a1b93cf (diff)
refactor: re-export anyhow from deno_core (#12777)
Diffstat (limited to 'core/ops_builtin.rs')
-rw-r--r--core/ops_builtin.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs
index a6cf82fe9..d759bc5ba 100644
--- a/core/ops_builtin.rs
+++ b/core/ops_builtin.rs
@@ -1,5 +1,4 @@
use crate::error::type_error;
-use crate::error::AnyError;
use crate::include_js_files;
use crate::op_async;
use crate::op_sync;
@@ -11,6 +10,7 @@ use crate::Extension;
use crate::OpState;
use crate::Resource;
use crate::ZeroCopyBuf;
+use anyhow::Error;
use std::cell::RefCell;
use std::io::{stderr, stdout, Write};
use std::rc::Rc;
@@ -51,7 +51,7 @@ pub fn op_resources(
state: &mut OpState,
_: (),
_: (),
-) -> Result<Vec<(ResourceId, String)>, AnyError> {
+) -> Result<Vec<(ResourceId, String)>, Error> {
let serialized_resources = state
.resource_table
.names()
@@ -65,7 +65,7 @@ pub fn op_close(
state: &mut OpState,
rid: Option<ResourceId>,
_: (),
-) -> Result<(), AnyError> {
+) -> Result<(), Error> {
// TODO(@AaronO): drop Option after improving type-strictness balance in
// serde_v8
let rid = rid.ok_or_else(|| type_error("missing or invalid `rid`"))?;
@@ -79,7 +79,7 @@ pub fn op_try_close(
state: &mut OpState,
rid: Option<ResourceId>,
_: (),
-) -> Result<(), AnyError> {
+) -> Result<(), Error> {
// TODO(@AaronO): drop Option after improving type-strictness balance in
// serde_v8.
let rid = rid.ok_or_else(|| type_error("missing or invalid `rid`"))?;
@@ -92,7 +92,7 @@ pub fn op_print(
_state: &mut OpState,
msg: String,
is_err: bool,
-) -> Result<(), AnyError> {
+) -> Result<(), Error> {
if is_err {
stderr().write_all(msg.as_bytes())?;
stderr().flush().unwrap();
@@ -123,7 +123,7 @@ pub fn op_wasm_streaming_feed(
state: &mut OpState,
rid: ResourceId,
bytes: ZeroCopyBuf,
-) -> Result<(), AnyError> {
+) -> Result<(), Error> {
let wasm_streaming =
state.resource_table.get::<WasmStreamingResource>(rid)?;
@@ -137,7 +137,7 @@ pub fn op_wasm_streaming_abort(
state: &mut OpState,
rid: ResourceId,
exception: serde_v8::Value,
-) -> Result<(), AnyError> {
+) -> Result<(), Error> {
let wasm_streaming =
state.resource_table.take::<WasmStreamingResource>(rid)?;
@@ -157,7 +157,7 @@ pub fn op_wasm_streaming_set_url(
state: &mut OpState,
rid: ResourceId,
url: String,
-) -> Result<(), AnyError> {
+) -> Result<(), Error> {
let wasm_streaming =
state.resource_table.get::<WasmStreamingResource>(rid)?;
@@ -170,7 +170,7 @@ pub fn op_metrics(
state: &mut OpState,
_: (),
_: (),
-) -> Result<(OpMetrics, Vec<OpMetrics>), AnyError> {
+) -> Result<(OpMetrics, Vec<OpMetrics>), Error> {
let aggregate = state.tracker.aggregate();
let per_op = state.tracker.per_op();
Ok((aggregate, per_op))
@@ -180,7 +180,7 @@ async fn op_read(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
buf: ZeroCopyBuf,
-) -> Result<u32, AnyError> {
+) -> Result<u32, Error> {
let resource = state.borrow().resource_table.get_any(rid)?;
resource.read(buf).await.map(|n| n as u32)
}
@@ -189,7 +189,7 @@ async fn op_write(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
buf: ZeroCopyBuf,
-) -> Result<u32, AnyError> {
+) -> Result<u32, Error> {
let resource = state.borrow().resource_table.get_any(rid)?;
resource.write(buf).await.map(|n| n as u32)
}
@@ -198,7 +198,7 @@ async fn op_shutdown(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
_: (),
-) -> Result<(), AnyError> {
+) -> Result<(), Error> {
let resource = state.borrow().resource_table.get_any(rid)?;
resource.shutdown().await
}