Skip to content

Commit abb9b34

Browse files
authored
Merge pull request #27 from pfreitag/patch-2
Add throwOnPostError setting to throw exception
2 parents 9197403 + d266f32 commit abb9b34

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

models/SentryService.cfc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ component accessors=true singleton {
105105
'logger' = 'sentry',
106106
'userInfoUDF' = '',
107107
'extraInfoUdfs' = {},
108-
'showJavaStackTrace' = false
108+
'showJavaStackTrace' = false,
109+
'throwOnPostError' = false
109110
};
110111
}
111112

@@ -756,11 +757,13 @@ component accessors=true singleton {
756757
cfhttpparam(type="body",value=arguments.json);
757758
}
758759

759-
if( find( "400", http.statuscode ) || find( "500", http.statuscode ) ){
760-
writeDump( var="Error posting to Sentry: #http.statuscode# - #left( http.filecontent, 1000 )#", output='console' );
761-
// TODO : Honor Sentry’s HTTP 429 Retry-After header any other errors
762-
} else if (!find("200",http.statuscode)){
763-
writeDump( var="Error posting to Sentry: #http.statuscode# - #left( http.filecontent, 1000 )#", output='console' );
760+
if( find( "400", http.statuscode ) || find( "500", http.statuscode ) || !find("200",http.statuscode) ){
761+
if ( settings.throwOnPostError ) {
762+
throw( message="Error posting to Sentry: #http.statuscode#", detail=http.filecontent );
763+
} else {
764+
writeDump( var="Error posting to Sentry: #http.statuscode# - #left( http.filecontent, 1000 )#", output='console' );
765+
}
766+
// TODO : Honor Sentry’s HTTP 429 Retry-After header any other errors
764767
}
765768
}
766769

0 commit comments

Comments
 (0)