Skip to content

Commit 579fec4

Browse files
committed
Merge branch 'development'
2 parents 34b264e + 3608512 commit 579fec4

2 files changed

Lines changed: 34 additions & 7 deletions

File tree

box.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name":"Sentry",
33
"author":"Ortus Solutions <info@ortussolutions.com>",
4-
"version":"2.0.0",
4+
"version":"2.0.1",
55
"slug":"sentry",
66
"type":"modules",
77
"homepage":"https://github.com/coldbox-modules/sentry",

models/SentryService.cfc

Lines changed: 33 additions & 6 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;
@@ -629,7 +642,7 @@ component accessors=true singleton {
629642
var signature = "";
630643
var header = "";
631644
var timeVars = getTimeVars();
632-
var httpRequestData = getHTTPRequestData();
645+
var httpRequestData = getHTTPDataForRequest();
633646

634647
// Add global metadata
635648
arguments.captureStruct[ "event_id" ] = lCase( replace( createUUID(), "-", "", "all" ) );
@@ -869,7 +882,7 @@ component accessors=true singleton {
869882
* Get Real IP, by looking at clustered, proxy headers and locally.
870883
*/
871884
private function getRealIP(){
872-
var headers = getHTTPRequestData().headers;
885+
var headers = getHTTPDataForRequest().headers;
873886

874887
// When going through a proxy, the IP can be a delimtied list, thus we take the last one in the list
875888

@@ -982,4 +995,18 @@ component accessors=true singleton {
982995
return normalizedPath.replace( "//", "/", "all" );
983996
}
984997

998+
/**
999+
* I return the http request data
1000+
*/
1001+
struct function getHTTPDataForRequest() {
1002+
try {
1003+
var result = getHTTPRequestData();
1004+
if ( !isNull( result ) ) {
1005+
return result;
1006+
}
1007+
} catch ( any e ) {
1008+
}
1009+
return { "headers" : {}, "content" : "" };
1010+
}
1011+
9851012
}

0 commit comments

Comments
 (0)