99 SafeMap,
1010 StringPrototypeCharCodeAt,
1111 StringPrototypeIncludes,
12- StringPrototypeIndexOf,
1312 StringPrototypeReplace,
1413 StringPrototypeSlice,
1514 StringPrototypeSplit,
@@ -174,7 +173,6 @@ function getErrMessage(message, fn) {
174173 const line = call . getLineNumber ( ) - 1 ;
175174 let column = call . getColumnNumber ( ) - 1 ;
176175 let identifier ;
177- let code ;
178176
179177 if ( filename ) {
180178 identifier = `${ filename } ${ line } ${ column } ` ;
@@ -199,31 +197,24 @@ function getErrMessage(message, fn) {
199197 // errors are handled faster.
200198 if ( errorStackTraceLimitIsWritable ) Error . stackTraceLimit = 0 ;
201199
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+ }
214204
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 ) ;
226210 }
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+
227218 // Always normalize indentation, otherwise the message could look weird.
228219 if ( StringPrototypeIncludes ( message , '\n' ) ) {
229220 if ( EOL === '\r\n' ) {
0 commit comments