JaxRsExceptionResponseBuilder { public final boolean canHandle(final Exception exception) { Throwable cause = exception.getCause(); if (cause instanceof CandlepinParameterParseException) { return true; } String msg = exception.getMessage(); if (StringUtils.isNotEmpty(msg)) { Matcher paramMatcher = PARAM_REGEX.matcher(msg); Matcher illegalValMatcher = ILLEGAL_VAL_REGEX.matcher(msg); if (paramMatcher.find() && illegalValMatcher.find()) { if ((paramMatcher.groupCount() == 2) && (illegalValMatcher.groupCount() == 2)) { return true; } } } return false; }  final boolean canHandle(final Exception exception); final Response getResponse(final Exception exception);  }
@Test public void badExceptionNotHandleable() { String foo = "javax.Xs.rs.SomeThing(\"paramName\") value is 'strVal' for"; assertFalse(exceptionBuilder.canHandle(new RuntimeException(foo))); }
@Test public void badMessageNotHandleable() { String foo = "javax.ws.rs.SomeThing(\"paramName\") value is strVal for"; assertFalse(exceptionBuilder.canHandle(new RuntimeException(foo))); }