9
9
SafeMap,
10
10
StringPrototypeCharCodeAt,
11
11
StringPrototypeIncludes,
12
- StringPrototypeIndexOf,
13
12
StringPrototypeReplace,
14
13
StringPrototypeSlice,
15
14
StringPrototypeSplit,
@@ -174,7 +173,6 @@ function getErrMessage(message, fn) {
174
173
const line = call . getLineNumber ( ) - 1 ;
175
174
let column = call . getColumnNumber ( ) - 1 ;
176
175
let identifier ;
177
- let code ;
178
176
179
177
if ( filename ) {
180
178
identifier = `${ filename } ${ line } ${ column } ` ;
@@ -199,31 +197,24 @@ function getErrMessage(message, fn) {
199
197
// errors are handled faster.
200
198
if ( errorStackTraceLimitIsWritable ) Error . stackTraceLimit = 0 ;
201
199
202
- if ( filename ) {
203
- if ( decoder === undefined ) {
204
- const { StringDecoder } = require ( 'string_decoder' ) ;
205
- decoder = new StringDecoder ( 'utf8' ) ;
206
- }
207
-
208
- // ESM file prop is a file proto. Convert that to path.
209
- // This ensure opensync will not throw ENOENT for ESM files.
210
- const fileProtoPrefix = 'file://' ;
211
- if ( StringPrototypeStartsWith ( filename , fileProtoPrefix ) ) {
212
- filename = fileURLToPath ( filename ) ;
213
- }
200
+ if ( decoder === undefined ) {
201
+ const { StringDecoder } = require ( 'string_decoder' ) ;
202
+ decoder = new StringDecoder ( 'utf8' ) ;
203
+ }
214
204
215
- fd = openSync ( filename , 'r' , 0o666 ) ;
216
- // Reset column and message.
217
- ( { 0 : column , 1 : message } = getCode ( fd , line , column ) ) ;
218
- // Flush unfinished multi byte characters.
219
- decoder . end ( ) ;
220
- } else {
221
- for ( let i = 0 ; i < line ; i ++ ) {
222
- code = StringPrototypeSlice ( code ,
223
- StringPrototypeIndexOf ( code , '\n' ) + 1 ) ;
224
- }
225
- ( { 0 : column , 1 : message } = parseCode ( code , column ) ) ;
205
+ // ESM file prop is a file proto. Convert that to path.
206
+ // This ensure opensync will not throw ENOENT for ESM files.
207
+ const fileProtoPrefix = 'file://' ;
208
+ if ( StringPrototypeStartsWith ( filename , fileProtoPrefix ) ) {
209
+ filename = fileURLToPath ( filename ) ;
226
210
}
211
+
212
+ fd = openSync ( filename , 'r' , 0o666 ) ;
213
+ // Reset column and message.
214
+ ( { 0 : column , 1 : message } = getCode ( fd , line , column ) ) ;
215
+ // Flush unfinished multi byte characters.
216
+ decoder . end ( ) ;
217
+
227
218
// Always normalize indentation, otherwise the message could look weird.
228
219
if ( StringPrototypeIncludes ( message , '\n' ) ) {
229
220
if ( EOL === '\r\n' ) {
0 commit comments