@@ -555,21 +555,34 @@ component accessors=true singleton {
555555 this StackItem .pre_context [ 1 ] = fileArray [ errorLine - 3 ];
556556 }
557557 if ( errorLine - 2 >= 1 && errorLine - 2 <= fileLen ) {
558- this StackItem .pre_context [ 1 ] = fileArray [ errorLine - 2 ];
558+ this StackItem .pre_context [ 2 ] = fileArray [ errorLine - 2 ];
559559 }
560560 if ( errorLine - 1 >= 1 && errorLine - 1 <= fileLen ) {
561- this StackItem .pre_context [ 2 ] = fileArray [ errorLine - 1 ];
561+ this StackItem .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- this StackItem .post_context [ 1 ] = fileArray [ errorLine + 1 ];
569+ var errorLine1 = errorLine + 1 ;
570+
571+ if (errorLine1 ! = 0 ) {
572+ this StackItem .post_context [ 1 ] = fileArray [ errorLine1 ];
573+ } else if (fileLen >= errorLine1 + 1 ) {
574+ this StackItem .post_context [ 1 ] = fileArray [ errorLine1 + 1 ];
575+ }
570576 }
577+
571578 if ( fileLen >= errorLine + 2 ) {
572- this StackItem .post_context [ 2 ] = fileArray [ errorLine + 2 ];
579+ var errorLine2 = errorLine + 2 ;
580+
581+ if (errorLine2 ! = 1 ) {
582+ this StackItem .post_context [ 2 ] = fileArray [ errorLine2 ];
583+ } else if (fileLen >= errorLine2 + 1 ) {
584+ this StackItem .post_context [ 2 ] = fileArray [ errorLine2 + 1 ];
585+ }
573586 }
574587
575588 currentException [ " stacktrace" ][ " frames" ][ stacki ] = this StackItem ;
@@ -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