Skip to content

Commit 4b010cd

Browse files
committed
Pass through custom error type factory
1 parent 71c8717 commit 4b010cd

File tree

19 files changed

+587
-399
lines changed

19 files changed

+587
-399
lines changed

Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ dhat = { version = "0.3.2" }
349349
dunce = "1.0.3"
350350
either = "1.9.0"
351351
erased-serde = "0.4.5"
352-
futures = "0.3.26"
352+
futures = "0.3.31"
353+
futures-util = "0.3.31"
353354
futures-retry = "0.6.0"
354355
hashbrown = "0.14.5"
355356
image = { version = "0.25.0", default-features = false }

crates/napi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ anyhow = "1.0.66"
5858
console-subscriber = { workspace = true, optional = true }
5959
dhat = { workspace = true, optional = true }
6060
either = { workspace = true }
61+
futures-util = { workspace = true }
6162
owo-colors = { workspace = true }
6263
napi = { workspace = true }
6364
napi-derive = "2"

crates/napi/src/next_api/endpoint.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{ops::Deref, sync::Arc};
22

33
use anyhow::Result;
4+
use futures_util::TryFutureExt;
45
use napi::{JsFunction, bindgen_prelude::External};
56
use next_api::{
67
operation::OptionEndpoint,
@@ -12,7 +13,7 @@ use next_api::{
1213
};
1314
use tracing::Instrument;
1415
use turbo_tasks::{Completion, Effects, OperationVc, ReadRef, Vc};
15-
use turbopack_core::{diagnostics::PlainDiagnostic, error::PrettyPrintError, issue::PlainIssue};
16+
use turbopack_core::{diagnostics::PlainDiagnostic, issue::PlainIssue};
1617

1718
use super::utils::{
1819
DetachedVc, NapiDiagnostic, NapiIssue, RootTask, TurbopackResult,
@@ -125,6 +126,7 @@ async fn get_written_endpoint_with_issues_operation(
125126
pub async fn endpoint_write_to_disk(
126127
#[napi(ts_arg_type = "{ __napiType: \"Endpoint\" }")] endpoint: External<ExternalEndpoint>,
127128
) -> napi::Result<TurbopackResult<NapiWrittenEndpoint>> {
129+
let ctx = endpoint.turbopack_ctx();
128130
let endpoint_op = ***endpoint;
129131
let (written, issues, diags) = endpoint
130132
.turbopack_ctx()
@@ -144,8 +146,8 @@ pub async fn endpoint_write_to_disk(
144146

145147
Ok((written.clone(), issues.clone(), diagnostics.clone()))
146148
})
147-
.await
148-
.map_err(|e| napi::Error::from_reason(PrettyPrintError(&e).to_string()))?;
149+
.or_else(|e| ctx.throw_turbopack_internal_result(&e))
150+
.await?;
149151
Ok(TurbopackResult {
150152
result: NapiWrittenEndpoint::from(written.map(ReadRef::into_owned)),
151153
issues: issues.iter().map(|i| NapiIssue::from(&**i)).collect(),

0 commit comments

Comments
 (0)