Unverified Commit 99d64f3a authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

[turbopack] Use bail! instead of panic! for duplicate module ident error (#91636)

### What?

In `turbopack/crates/turbopack-core/src/module_graph/mod.rs`, the
`#[cfg(debug_assertions)]` duplicate module ident detection block inside
`SingleModuleGraph::new_inner` called `panic!` when duplicates were
found.

### Why?

`panic!` terminates the process hard, bypassing the normal
error-handling chain. The enclosing function `new_inner` already returns
`anyhow::Result<Vc<Self>>`, and `bail!` is already imported and used
elsewhere in the same file. Using `bail!` converts this into a
propagatable error, consistent with the rest of the error-handling
idioms in the module.

### How?

Single-line change: replace `panic!(...)` with `bail!(...)` at the
duplicate module detection site. No new imports needed — `bail!` was
already in scope via `use anyhow::{Context, Result, bail};`.
Co-authored-by: 's avatarTobias Koppers <sokra@users.noreply.github.com>
Co-authored-by: 's avatarClaude <noreply@anthropic.com>
parent 6836c26b
...@@ -406,7 +406,7 @@ impl SingleModuleGraph { ...@@ -406,7 +406,7 @@ impl SingleModuleGraph {
for (key, debug, parents) in duplicate_modules { for (key, debug, parents) in duplicate_modules {
map.entry(key).or_default().push((debug, parents)); map.entry(key).or_default().push((debug, parents));
} }
panic!("Duplicate module idents in graph: {map:#?}",); bail!("Duplicate module idents in graph: {map:#?}",);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment