Skip to content

Commit 5140f22

Browse files
fix: better
1 parent cfe210a commit 5140f22

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

src/utils.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,19 +887,18 @@ function normalizeSourceMap(map, rootContext) {
887887

888888
function errorFactory(error) {
889889
let message;
890-
let stack = null;
891890

892891
if (error.formatted) {
893-
message = error.formatted.replace(/^Error: /, "");
892+
message = error.formatted.replace(/^(.+)?Error: /, "");
894893
} else {
895894
// Keep original error if `sassError.formatted` is unavailable
896-
message = error.message || error.toString();
897-
stack = error.stack || (error.$thrownJsError && error.$thrownJsError.stack);
895+
message = (error.message || error.toString()).replace(/^(.+)?Error: /, "");
898896
}
899897

900898
const obj = new Error(message, { cause: error });
901899

902-
obj.stack = stack;
900+
obj.name = error.name;
901+
obj.stack = null;
903902

904903
return obj;
905904
}

test/__snapshots__/sassOptions-option.test.js.no-node-sass.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ exports[`sassOptions option should ignore the "url" option ('sass-embedded', 'mo
12271227
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = `
12281228
[
12291229
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1230-
TypeError: J.getInterceptor$ax(...).get$iterator is not a function",
1230+
method not found: 'get$iterator' (J.getInterceptor$ax(...).get$iterator is not a function)",
12311231
]
12321232
`;
12331233

@@ -1236,7 +1236,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
12361236
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = `
12371237
[
12381238
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1239-
TypeError: J.getInterceptor$ax(...).get$iterator is not a function",
1239+
method not found: 'get$iterator' (J.getInterceptor$ax(...).get$iterator is not a function)",
12401240
]
12411241
`;
12421242

@@ -1245,7 +1245,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
12451245
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('dart-sass', 'modern-compiler' API, 'sass' syntax): errors 1`] = `
12461246
[
12471247
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1248-
TypeError: J.getInterceptor$ax(...).get$iterator is not a function",
1248+
method not found: 'get$iterator' (J.getInterceptor$ax(...).get$iterator is not a function)",
12491249
]
12501250
`;
12511251

@@ -1254,7 +1254,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
12541254
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('dart-sass', 'modern-compiler' API, 'scss' syntax): errors 1`] = `
12551255
[
12561256
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1257-
TypeError: J.getInterceptor$ax(...).get$iterator is not a function",
1257+
method not found: 'get$iterator' (J.getInterceptor$ax(...).get$iterator is not a function)",
12581258
]
12591259
`;
12601260

@@ -1263,7 +1263,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
12631263
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = `
12641264
[
12651265
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1266-
TypeError: arr.flatMap is not a function",
1266+
arr.flatMap is not a function",
12671267
]
12681268
`;
12691269

@@ -1272,7 +1272,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
12721272
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = `
12731273
[
12741274
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1275-
TypeError: arr.flatMap is not a function",
1275+
arr.flatMap is not a function",
12761276
]
12771277
`;
12781278

@@ -1281,7 +1281,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
12811281
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('sass-embedded', 'modern-compiler' API, 'sass' syntax): errors 1`] = `
12821282
[
12831283
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1284-
TypeError: arr.flatMap is not a function",
1284+
arr.flatMap is not a function",
12851285
]
12861286
`;
12871287

@@ -1290,7 +1290,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
12901290
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('sass-embedded', 'modern-compiler' API, 'scss' syntax): errors 1`] = `
12911291
[
12921292
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1293-
TypeError: arr.flatMap is not a function",
1293+
arr.flatMap is not a function",
12941294
]
12951295
`;
12961296

@@ -4463,7 +4463,7 @@ exports[`sassOptions option should work with custom scheme import ('sass-embedde
44634463
exports[`sassOptions option should work with the "fatalDeprecations" option ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = `
44644464
[
44654465
"ModuleBuildError: Module build failed (from ../src/cjs.js):
4466-
Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
4466+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
44674467
]
44684468
`;
44694469

@@ -4472,7 +4472,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('da
44724472
exports[`sassOptions option should work with the "fatalDeprecations" option ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = `
44734473
[
44744474
"ModuleBuildError: Module build failed (from ../src/cjs.js):
4475-
Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
4475+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
44764476
]
44774477
`;
44784478

@@ -4481,7 +4481,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('da
44814481
exports[`sassOptions option should work with the "fatalDeprecations" option ('dart-sass', 'modern-compiler' API, 'sass' syntax): errors 1`] = `
44824482
[
44834483
"ModuleBuildError: Module build failed (from ../src/cjs.js):
4484-
Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
4484+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
44854485
]
44864486
`;
44874487

@@ -4490,7 +4490,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('da
44904490
exports[`sassOptions option should work with the "fatalDeprecations" option ('dart-sass', 'modern-compiler' API, 'scss' syntax): errors 1`] = `
44914491
[
44924492
"ModuleBuildError: Module build failed (from ../src/cjs.js):
4493-
Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
4493+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
44944494
]
44954495
`;
44964496

@@ -4499,7 +4499,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('da
44994499
exports[`sassOptions option should work with the "fatalDeprecations" option ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = `
45004500
[
45014501
"ModuleBuildError: Module build failed (from ../src/cjs.js):
4502-
Error: Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
4502+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
45034503
]
45044504
`;
45054505

@@ -4508,7 +4508,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('sa
45084508
exports[`sassOptions option should work with the "fatalDeprecations" option ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = `
45094509
[
45104510
"ModuleBuildError: Module build failed (from ../src/cjs.js):
4511-
Error: Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
4511+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
45124512
]
45134513
`;
45144514

@@ -4517,7 +4517,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('sa
45174517
exports[`sassOptions option should work with the "fatalDeprecations" option ('sass-embedded', 'modern-compiler' API, 'sass' syntax): errors 1`] = `
45184518
[
45194519
"ModuleBuildError: Module build failed (from ../src/cjs.js):
4520-
Error: Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
4520+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
45214521
]
45224522
`;
45234523

@@ -4526,7 +4526,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('sa
45264526
exports[`sassOptions option should work with the "fatalDeprecations" option ('sass-embedded', 'modern-compiler' API, 'scss' syntax): errors 1`] = `
45274527
[
45284528
"ModuleBuildError: Module build failed (from ../src/cjs.js):
4529-
Error: Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
4529+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
45304530
]
45314531
`;
45324532

test/__snapshots__/sassOptions-option.test.js.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ exports[`sassOptions option should ignore the "url" option ('sass-embedded', 'mo
14071407
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = `
14081408
[
14091409
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1410-
TypeError: J.getInterceptor$ax(...).get$iterator is not a function",
1410+
method not found: 'get$iterator' (J.getInterceptor$ax(...).get$iterator is not a function)",
14111411
]
14121412
`;
14131413

@@ -1416,7 +1416,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
14161416
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = `
14171417
[
14181418
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1419-
TypeError: J.getInterceptor$ax(...).get$iterator is not a function",
1419+
method not found: 'get$iterator' (J.getInterceptor$ax(...).get$iterator is not a function)",
14201420
]
14211421
`;
14221422

@@ -1425,7 +1425,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
14251425
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('dart-sass', 'modern-compiler' API, 'sass' syntax): errors 1`] = `
14261426
[
14271427
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1428-
TypeError: J.getInterceptor$ax(...).get$iterator is not a function",
1428+
method not found: 'get$iterator' (J.getInterceptor$ax(...).get$iterator is not a function)",
14291429
]
14301430
`;
14311431

@@ -1434,7 +1434,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
14341434
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('dart-sass', 'modern-compiler' API, 'scss' syntax): errors 1`] = `
14351435
[
14361436
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1437-
TypeError: J.getInterceptor$ax(...).get$iterator is not a function",
1437+
method not found: 'get$iterator' (J.getInterceptor$ax(...).get$iterator is not a function)",
14381438
]
14391439
`;
14401440

@@ -1443,7 +1443,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
14431443
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = `
14441444
[
14451445
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1446-
TypeError: arr.flatMap is not a function",
1446+
arr.flatMap is not a function",
14471447
]
14481448
`;
14491449

@@ -1452,7 +1452,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
14521452
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = `
14531453
[
14541454
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1455-
TypeError: arr.flatMap is not a function",
1455+
arr.flatMap is not a function",
14561456
]
14571457
`;
14581458

@@ -1461,7 +1461,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
14611461
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('sass-embedded', 'modern-compiler' API, 'sass' syntax): errors 1`] = `
14621462
[
14631463
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1464-
TypeError: arr.flatMap is not a function",
1464+
arr.flatMap is not a function",
14651465
]
14661466
`;
14671467

@@ -1470,7 +1470,7 @@ exports[`sassOptions option should output a normal error with the wrong "fatalDe
14701470
exports[`sassOptions option should output a normal error with the wrong "fatalDeprecations" option ('sass-embedded', 'modern-compiler' API, 'scss' syntax): errors 1`] = `
14711471
[
14721472
"ModuleBuildError: Module build failed (from ../src/cjs.js):
1473-
TypeError: arr.flatMap is not a function",
1473+
arr.flatMap is not a function",
14741474
]
14751475
`;
14761476

@@ -5129,7 +5129,7 @@ exports[`sassOptions option should work with custom scheme import ('sass-embedde
51295129
exports[`sassOptions option should work with the "fatalDeprecations" option ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = `
51305130
[
51315131
"ModuleBuildError: Module build failed (from ../src/cjs.js):
5132-
Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
5132+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
51335133
]
51345134
`;
51355135

@@ -5138,7 +5138,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('da
51385138
exports[`sassOptions option should work with the "fatalDeprecations" option ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = `
51395139
[
51405140
"ModuleBuildError: Module build failed (from ../src/cjs.js):
5141-
Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
5141+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
51425142
]
51435143
`;
51445144

@@ -5147,7 +5147,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('da
51475147
exports[`sassOptions option should work with the "fatalDeprecations" option ('dart-sass', 'modern-compiler' API, 'sass' syntax): errors 1`] = `
51485148
[
51495149
"ModuleBuildError: Module build failed (from ../src/cjs.js):
5150-
Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
5150+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
51515151
]
51525152
`;
51535153

@@ -5156,7 +5156,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('da
51565156
exports[`sassOptions option should work with the "fatalDeprecations" option ('dart-sass', 'modern-compiler' API, 'scss' syntax): errors 1`] = `
51575157
[
51585158
"ModuleBuildError: Module build failed (from ../src/cjs.js):
5159-
Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
5159+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
51605160
]
51615161
`;
51625162

@@ -5165,7 +5165,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('da
51655165
exports[`sassOptions option should work with the "fatalDeprecations" option ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = `
51665166
[
51675167
"ModuleBuildError: Module build failed (from ../src/cjs.js):
5168-
Error: Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
5168+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
51695169
]
51705170
`;
51715171

@@ -5174,7 +5174,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('sa
51745174
exports[`sassOptions option should work with the "fatalDeprecations" option ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = `
51755175
[
51765176
"ModuleBuildError: Module build failed (from ../src/cjs.js):
5177-
Error: Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
5177+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
51785178
]
51795179
`;
51805180

@@ -5183,7 +5183,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('sa
51835183
exports[`sassOptions option should work with the "fatalDeprecations" option ('sass-embedded', 'modern-compiler' API, 'sass' syntax): errors 1`] = `
51845184
[
51855185
"ModuleBuildError: Module build failed (from ../src/cjs.js):
5186-
Error: Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
5186+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
51875187
]
51885188
`;
51895189

@@ -5192,7 +5192,7 @@ exports[`sassOptions option should work with the "fatalDeprecations" option ('sa
51925192
exports[`sassOptions option should work with the "fatalDeprecations" option ('sass-embedded', 'modern-compiler' API, 'scss' syntax): errors 1`] = `
51935193
[
51945194
"ModuleBuildError: Module build failed (from ../src/cjs.js):
5195-
Error: Error: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
5195+
Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.",
51965196
]
51975197
`;
51985198

0 commit comments

Comments
 (0)