Skip to content

Commit 6b052b1

Browse files
authored
Merge pull request #30 from TwizzX17/development
Negative line number and pre_context change
2 parents ec1ee2a + 4973a3b commit 6b052b1

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

models/SentryService.cfc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,21 +555,34 @@ component accessors=true singleton {
555555
thisStackItem.pre_context[ 1 ] = fileArray[ errorLine - 3 ];
556556
}
557557
if ( errorLine - 2 >= 1 && errorLine - 2 <= fileLen ) {
558-
thisStackItem.pre_context[ 1 ] = fileArray[ errorLine - 2 ];
558+
thisStackItem.pre_context[ 2 ] = fileArray[ errorLine - 2 ];
559559
}
560560
if ( errorLine - 1 >= 1 && errorLine - 1 <= fileLen ) {
561-
thisStackItem.pre_context[ 2 ] = fileArray[ errorLine - 1 ];
561+
thisStackItem.pre_context[ 3 ] = fileArray[ errorLine - 1 ];
562562
}
563563

564564
if ( errorLine <= fileLen ) {
565565
thisStackItem[ "context_line" ] = fileArray[ errorLine ];
566566
}
567567

568568
if ( fileLen >= errorLine + 1 ) {
569-
thisStackItem.post_context[ 1 ] = fileArray[ errorLine + 1 ];
569+
var errorLine1 = errorLine + 1;
570+
571+
if (errorLine1 != 0) {
572+
thisStackItem.post_context[ 1 ] = fileArray[ errorLine1 ];
573+
} else if (fileLen >= errorLine1 + 1) {
574+
thisStackItem.post_context[ 1 ] = fileArray[ errorLine1 + 1 ];
575+
}
570576
}
577+
571578
if ( fileLen >= errorLine + 2 ) {
572-
thisStackItem.post_context[ 2 ] = fileArray[ errorLine + 2 ];
579+
var errorLine2 = errorLine + 2;
580+
581+
if (errorLine2 != 1) {
582+
thisStackItem.post_context[ 2 ] = fileArray[ errorLine2 ];
583+
} else if (fileLen >= errorLine2 + 1) {
584+
thisStackItem.post_context[ 2 ] = fileArray[ errorLine2 + 1 ];
585+
}
573586
}
574587

575588
currentException[ "stacktrace" ][ "frames" ][ stacki ] = thisStackItem;

0 commit comments

Comments
 (0)