File tree Expand file tree Collapse file tree 1 file changed +22
-8
lines changed
Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -70,14 +70,28 @@ export default class StackParser {
7070 const linesCollectCount = 5 ;
7171 const lineFrom = Math . max ( 0 , actualLineNumber - linesCollectCount ) ;
7272 const lineTo = Math . min ( lines . length - 1 , actualLineNumber + linesCollectCount + 1 ) ;
73- const linesToCollect = lines . slice ( lineFrom , lineTo ) ;
74-
75- return linesToCollect . map ( ( content , index ) => {
76- return {
77- line : lineFrom + index + 1 ,
78- content,
79- } ;
80- } ) ;
73+
74+ const sourceCodeLines : SourceCodeLine [ ] = [ ] ;
75+ let extractedLineIndex = 1 ;
76+
77+ /**
78+ * In some cases column number of the error stack trace frame would be less then 200, but source code is minified
79+ * For this cases we need to check, that all of the lines to collect have length less than 200 too
80+ */
81+ for ( const lineToCheck in lines . slice ( lineFrom , lineTo ) ) {
82+ if ( lineToCheck . length > 200 ) {
83+ return null ;
84+ } else {
85+ sourceCodeLines . push ( {
86+ line : lineFrom + extractedLineIndex ,
87+ content : lineToCheck ,
88+ } ) ;
89+
90+ extractedLineIndex += 1 ;
91+ }
92+ }
93+
94+ return sourceCodeLines ;
8195 } catch ( e ) {
8296 console . warn ( 'Hawk JS SDK: Can not extract source code. Please, report this issue: https://github.com/codex-team/hawk.javascript/issues/new' , e ) ;
8397
You can’t perform that action at this time.
0 commit comments