-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Milestone
Description
Describe the feature
The try_with_handler should return a SwcError instead of anyhow!(msg), it's helper upper application such as deno, rspack can get more detail about error.
Swc have many kind error with invoke wasm plugin error, wasm plugin emit custom error, js parser error ...., So upper application need more detail to distinguish what the error kind.
Example
// crate swc_error_reporter
pub struct Error {
inner: Box<InnerError>
}
struct InnerError {
kind: ErrorKind,
message: Cow<str>,
....
}
impl Display for Error { .. }
fn try_with_handler(...) -> Result<T, Error> { ... }// rspack/core
match swc_try_with_handler {
Ok(program) => program,
Err(error) => {
match error.kind() {
// do somethings for different errors
}
},
}// node_binding
#[napi]
fn transform_sync(...) -> Result<T> {
swc_core::transform(...).map_err(|e: SwcError| anyhow!(e.to_string()))
}Babel plugin or link to the feature description
No response
Additional context
No response
Reactions are currently unavailable