Skip to content

Commit d266f32

Browse files
authored
Add throwOnPostError setting to throw exception
If the sentry endpoint is returning an error, it is hard to debug what is going on, the dump was not being output even when async=false.
1 parent 303c5a5 commit d266f32

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

@@ -734,11 +735,13 @@ component accessors=true singleton {
734735
cfhttpparam(type="body",value=arguments.json);
735736
}
736737

737-
if( find( "400", http.statuscode ) || find( "500", http.statuscode ) ){
738-
writeDump( var="Error posting to Sentry: #http.statuscode# - #left( http.filecontent, 1000 )#", output='console' );
739-
// TODO : Honor Sentry’s HTTP 429 Retry-After header any other errors
740-
} else if (!find("200",http.statuscode)){
741-
writeDump( var="Error posting to Sentry: #http.statuscode# - #left( http.filecontent, 1000 )#", output='console' );
738+
if( find( "400", http.statuscode ) || find( "500", http.statuscode ) || !find("200",http.statuscode) ){
739+
if ( settings.throwOnPostError ) {
740+
throw( message="Error posting to Sentry: #http.statuscode#", detail=http.filecontent );
741+
} else {
742+
writeDump( var="Error posting to Sentry: #http.statuscode# - #left( http.filecontent, 1000 )#", output='console' );
743+
}
744+
// TODO : Honor Sentry’s HTTP 429 Retry-After header any other errors
742745
}
743746
}
744747

0 commit comments

Comments
 (0)