Skip to content

Commit 92df1d0

Browse files
committed
fix: test case
1 parent 6674c56 commit 92df1d0

File tree

7 files changed

+2
-51
lines changed

7 files changed

+2
-51
lines changed

crates/node_binding/src/error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ impl RspackError {
317317
pub fn into_diagnostic(mut self, severity: RspackSeverity) -> Diagnostic {
318318
self.severity = Some(severity.into());
319319

320-
let message = self.message.clone();
321320
let details = self.details.clone();
322321
let file = self.file.clone();
323322
let loc = self.loc.as_ref().map(Into::into);
@@ -337,7 +336,6 @@ impl RspackError {
337336
};
338337

339338
diagnostic
340-
.with_message(message)
341339
.with_details(details)
342340
.with_file(file.map(Into::into))
343341
.with_loc(loc)

crates/rspack_error/src/diagnostic.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ pub struct Diagnostic {
7474

7575
// The following fields are only used to restore Diagnostic for Rspack.
7676
// If the current Diagnostic originates from Rust, these fields will be None.
77-
message: Option<String>,
7877
details: Option<String>,
7978
module_identifier: Option<Identifier>,
8079
loc: Option<DependencyLocation>,
@@ -94,7 +93,6 @@ impl From<miette::Error> for Diagnostic {
9493
fn from(value: miette::Error) -> Self {
9594
Self {
9695
inner: Arc::new(value),
97-
message: None,
9896
details: None,
9997
module_identifier: None,
10098
loc: None,
@@ -123,7 +121,6 @@ impl Diagnostic {
123121
.with_severity(miette::Severity::Warning),
124122
)
125123
.into(),
126-
message: None,
127124
details: None,
128125
module_identifier: None,
129126
loc: None,
@@ -142,7 +139,6 @@ impl Diagnostic {
142139
.with_severity(miette::Severity::Error),
143140
)
144141
.into(),
145-
message: None,
146142
details: None,
147143
module_identifier: None,
148144
loc: None,
@@ -170,27 +166,7 @@ impl Diagnostic {
170166
}
171167

172168
pub fn message(&self) -> String {
173-
match &self.message {
174-
Some(message) => message.clone(),
175-
None => {
176-
let mut name = "Error".to_string();
177-
if let Some(code) = self.inner.code() {
178-
name = code.to_string();
179-
}
180-
181-
let mut message = self.inner.to_string();
182-
let prefix = format!("{name}: ");
183-
if message.starts_with(&prefix) {
184-
message = message[prefix.len()..].to_string();
185-
}
186-
message
187-
}
188-
}
189-
}
190-
191-
pub fn with_message(mut self, message: String) -> Self {
192-
self.message = Some(message);
193-
self
169+
self.inner.to_string()
194170
}
195171

196172
pub fn severity(&self) -> Severity {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
module.exports = [
22
[/emit message hide/, { details: /emit stack hide/ }],
3-
[/emit stack/],
4-
[/throw message hide/, { details: /throw stack hide/ }],
5-
[/throw stack/],
3+
[/emit stack/]
64
]

packages/rspack-test-tools/tests/configCases/errors/hide-stack/index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
it("should hide stack in details when throw", function () {
2-
expect(function f() {
3-
require("./loader-throw!");
4-
require("./loader-throw-hide!");
5-
}).toThrowError();
6-
});
7-
81
it("should hide stack in details when emit", function () {
92
expect(function f() {
103
require("./loader-emit!");

packages/rspack-test-tools/tests/configCases/errors/hide-stack/loader-throw-hide.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/rspack-test-tools/tests/configCases/errors/hide-stack/loader-throw.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/rspack-test-tools/tests/configCases/errors/hide-stack/rspack.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module.exports = {
99
for (let error of errors) {
1010
if (error.message.includes("hide")) {
1111
expect(typeof error.details).toBe("string");
12-
expect(error.message.includes("stack")).toBeFalsy;
1312
} else {
1413
expect(typeof error.details).toBe("undefined");
1514
}

0 commit comments

Comments
 (0)