sknowlton
05/02/2022, 1:49 PMvalidateOrFail() on the request scope. We use the REST-HMVC template and so ValidationException is caught and dealt with, but it still triggers onException which triggers the Sentry Module. Consequently we're getting a Sentry entry for every single client validation failure. Is there a way we can specify the error level somewhere in the request or the exception, and then have Sentry's onException look for it and only default to error if it isn't there? That seems like the most correct way to reflect what's really going on, which is that some of these exceptions, being caught, shouldn't trigger the thing we have for actual CF errorswil-shiftinsert
05/02/2022, 2:31 PMwil-shiftinsert
05/02/2022, 2:41 PMYourSentryService from the sentryService in the sentry module and override the captureException method.
Create a default Exception type, check the exception.type against your own ignore list (ValidationException, maybe more…) and return null, or call super.captureException(…) if you don’t want to filter.
Next thing to do is override the wirebox mapping for sentryService@sentry and map it to your own version. You can do that in an afterAspectsLoad interceptor, which fires when all modules have loaded.sknowlton
05/02/2022, 2:42 PMcaptureException in ModuleConfig that gets registered in the onException interceptor check for a value in exception that would override "error"sknowlton
05/02/2022, 2:42 PMERRORsknowlton
05/02/2022, 2:43 PMwil-shiftinsert
05/02/2022, 2:45 PMsknowlton
05/02/2022, 2:47 PMwil-shiftinsert
05/02/2022, 2:47 PMsknowlton
05/02/2022, 2:50 PMsknowlton
05/02/2022, 2:50 PMsknowlton
05/02/2022, 2:51 PMwil-shiftinsert
05/02/2022, 2:54 PMwil-shiftinsert
05/02/2022, 3:01 PMbdw429s
05/03/2022, 12:16 AMenableExceptionLogging setting is turned on, the module simply listens to any time the onException interception point is announced and then sends it to Sentry
https://github.com/coldbox-modules/sentry/blob/development/ModuleConfig.cfc#L108bdw429s
05/03/2022, 12:17 AMtry {
model.validate();
} catch( validationException e ) {
// Deal with vaildation error
}
then the framework will never "see" that exception and neither will Sentrybdw429s
05/03/2022, 12:18 AMonException interception point.sknowlton
05/03/2022, 12:23 AMvar validateResults = validateOrFail( target = event.getCollection(), constraints = constraints ); which then triggers validateOrFail in cbvalidation which throws a validationException (on a custom validator, in this case a unique email checker). It's correctly caught by our baseHandler's validationException catch because the API repsonse object shows all the proper plumbing with the validation errors. But Sentry is reporting it as well.bdw429s
05/03/2022, 12:24 AMonexception?sknowlton
05/03/2022, 12:25 AMbdw429s
05/03/2022, 12:25 AMbdw429s
05/03/2022, 12:25 AMsknowlton
05/03/2022, 12:25 AMsknowlton
05/03/2022, 12:26 AMsknowlton
05/03/2022, 12:26 AMbdw429s
05/03/2022, 12:32 AMbdw429s
05/03/2022, 12:33 AMbdw429s
05/03/2022, 12:33 AMbdw429s
05/03/2022, 12:33 AMbdw429s
05/03/2022, 12:34 AMsknowlton
05/03/2022, 12:35 AMsknowlton
05/03/2022, 12:35 AMfunction aroundHandler( event, rc, prc, targetAction, eventArguments ) {
try {
(basehandler prep plumbing)
// Execute action
if ( !prc.response.getError() ) {
var actionResults = arguments.targetAction( argumentCollection = args );
}
}
catch ( ValidationException e ) {
(massage response object)
}
If aroundHandler weren't executing, prc.response wouldn't even be getting created, nor would the response object have all the things it's returning to usbdw429s
05/03/2022, 12:43 AMbdw429s
05/03/2022, 12:43 AMbdw429s
05/03/2022, 12:43 AMbdw429s
05/03/2022, 12:43 AMsknowlton
05/03/2022, 12:46 AM{
Extended Info: {
email: [
{
errorMetadata: {},
field: email,
message: The specified email address is unavailable or already belongs to a user in this league.,
rejectedValue: <mailto:someguy@gmail.com|someguy@gmail.com>,
validationData: {},
validationType: Unique User
}
]
}
}bdw429s
05/03/2022, 12:51 AMbdw429s
05/03/2022, 12:51 AMwil-shiftinsert
05/03/2022, 8:38 AMenableLogBoxAppender = false
for testing, the only route left would be the onException interception. Which shouldn’t fire if your aroundhandler has proper code to handle this. I think we used a similar setup and if I remember correctly I had to add error catching for validation exceptions. At least it was not there in older versions of the handler.sknowlton
05/03/2022, 1:00 PMsknowlton
05/03/2022, 1:00 PMbdw429s
05/03/2022, 1:04 PMwil-shiftinsert
05/03/2022, 1:07 PMsknowlton
05/03/2022, 1:07 PMwil-shiftinsert
05/03/2022, 1:11 PM// Validation Exceptions
catch ( "ValidationException" e ) {
arguments.exception = e;
this.onValidationException( argumentCollection = arguments );
}
if you abort with some clear message on the first line of your onValidationException method, you are absolutely sure your exception is caught in the right place.bdw429s
05/03/2022, 1:30 PMwil-shiftinsert
05/03/2022, 1:37 PMsknowlton
05/03/2022, 1:38 PMsknowlton
05/03/2022, 1:39 PMwil-shiftinsert
05/03/2022, 1:40 PM