Java Code Examples for org.apache.commons.lang.exception.ExceptionUtils#getRootCauseMessage()
The following examples show how to use
org.apache.commons.lang.exception.ExceptionUtils#getRootCauseMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogEventConvert.java From canal-1.1.3 with Apache License 2.0 | 6 votes |
private TableMeta getTableMeta(String dbName, String tbName, boolean useCache, EntryPosition position) { try { return tableMetaCache.getTableMeta(dbName, tbName, useCache, position); } catch (Throwable e) { String message = ExceptionUtils.getRootCauseMessage(e); if (filterTableError) { if (StringUtils.contains(message, "errorNumber=1146") && StringUtils.contains(message, "doesn't exist")) { return null; } else if (StringUtils.contains(message, "errorNumber=1142") && StringUtils.contains(message, "command denied")) { return null; } } throw new CanalParseException(e); } }
Example 2
Source File: SignaturesTest.java From camel-cookbook-examples with Apache License 2.0 | 6 votes |
@Test public void testMessageSigningMismatchedKeys() throws InterruptedException { MockEndpoint mockVerified = getMockEndpoint("mock:verified"); mockVerified.setExpectedMessageCount(0); MockEndpoint mockSigned = getMockEndpoint("mock:signed"); mockSigned.whenAnyExchangeReceived(new Processor() { @Override public void process(Exchange exchange) throws Exception { // let's override the key used by the verifying endpoint exchange.getIn().setHeader(DigitalSignatureConstants.KEYSTORE_ALIAS, "system_b"); } }); try { template.sendBody("direct:sign", "foo"); fail(); } catch (CamelExecutionException cex) { assertTrue(ExceptionUtils.getRootCause(cex) instanceof SignatureException); String rootCauseMessage = ExceptionUtils.getRootCauseMessage(cex); assertEquals("SignatureException: Cannot verify signature of exchange", rootCauseMessage); } }
Example 3
Source File: LogEventConvert.java From canal with Apache License 2.0 | 6 votes |
private TableMeta getTableMeta(String dbName, String tbName, boolean useCache, EntryPosition position) { try { return tableMetaCache.getTableMeta(dbName, tbName, useCache, position); } catch (Throwable e) { String message = ExceptionUtils.getRootCauseMessage(e); if (filterTableError) { if (StringUtils.contains(message, "errorNumber=1146") && StringUtils.contains(message, "doesn't exist")) { return null; } else if (StringUtils.contains(message, "errorNumber=1142") && StringUtils.contains(message, "command denied")) { return null; } } throw new CanalParseException(e); } }
Example 4
Source File: LogEventConvert.java From DBus with Apache License 2.0 | 5 votes |
private TableMeta getTableMeta(String dbName, String tbName, boolean useCache) { try { return tableMetaCache.getTableMeta(dbName, tbName, useCache); } catch (Exception e) { String message = ExceptionUtils.getRootCauseMessage(e); if (filterTableError) { if (StringUtils.contains(message, "errorNumber=1146") && StringUtils.contains(message, "doesn't exist")) { return null; } } throw new CanalParseException(e); } }
Example 5
Source File: LogEventConvert_old.java From DBus with Apache License 2.0 | 5 votes |
private TableMeta getTableMeta(String dbName, String tbName, boolean useCache) { try { return tableMetaCache.getTableMeta(dbName, tbName, useCache); } catch (Exception e) { String message = ExceptionUtils.getRootCauseMessage(e); if (filterTableError) { if (StringUtils.contains(message, "errorNumber=1146") && StringUtils.contains(message, "doesn't exist")) { return null; } } throw new CanalParseException(e); } }
Example 6
Source File: LogEventConvert.java From DBus with Apache License 2.0 | 5 votes |
private TableMeta getTableMeta(String dbName, String tbName, boolean useCache) { try { return tableMetaCache.getTableMeta(dbName, tbName, useCache); } catch (Exception e) { String message = ExceptionUtils.getRootCauseMessage(e); if (filterTableError) { if (StringUtils.contains(message, "errorNumber=1146") && StringUtils.contains(message, "doesn't exist")) { return null; } } throw new CanalParseException(e); } }
Example 7
Source File: SignaturesTest.java From camel-cookbook-examples with Apache License 2.0 | 5 votes |
@Test public void testMessageSigningMissingKey() throws InterruptedException { MockEndpoint mockVerified = getMockEndpoint("mock:verified"); mockVerified.setExpectedMessageCount(0); try { template.sendBodyAndHeader("direct:sign", "foo", DigitalSignatureConstants.KEYSTORE_ALIAS, "cheese"); fail(); } catch (CamelExecutionException cex) { assertTrue(ExceptionUtils.getRootCause(cex) instanceof IllegalStateException); String rootCauseMessage = ExceptionUtils.getRootCauseMessage(cex); assertTrue(rootCauseMessage.startsWith("IllegalStateException: Cannot sign message as no Private Key has been supplied.")); } }
Example 8
Source File: RetryStrategy.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
public GenericResponse invoke(GenericRequest genericRequest) throws TechnicalConnectorException { RetryStrategy.RetryContext ctx = new RetryStrategy.RetryContext(this.getCurrentEndpoint(genericRequest)); int alternatives = distributor.getAmountOfAlternatives(ctx.endpoint); for(int i = 0; i < alternatives; ++i) { String activeEndpoint = distributor.getActiveEndpoint(ctx.endpoint); if (!ctx.invokedEndpoints.contains(activeEndpoint)) { ctx.invokedEndpoints.add(activeEndpoint); genericRequest.setEndpoint(activeEndpoint); try { GenericResponse resp = super.call(genericRequest); if (ctx.alternativeActivated) { LOG.debug("Activating status page polling!"); distributor.activatePolling(); } return resp; } catch (RetryNextEndpointException var9) { LOG.error("Unable to invoke endpoint [{}], activating next one.", activeEndpoint, var9); try { distributor.activateNextEndPoint(activeEndpoint); ctx.alternativeActivated = true; } catch (NoNextEndpointException var8) { LOG.error("Unable to activate alternative", var8); } ctx.lastException = var9; } } else { LOG.debug("Endpoint [{}] already invoked, skipping it.", activeEndpoint); } } if (EndpointDistributor.update()) { return this.invoke(genericRequest); } else { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, ExceptionUtils.getRootCause(ctx.lastException), new Object[]{ExceptionUtils.getRootCauseMessage(ctx.lastException)}); } }
Example 9
Source File: RetryStrategy.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
public GenericResponse invoke(GenericRequest genericRequest) throws TechnicalConnectorException { RetryStrategy.RetryContext ctx = new RetryStrategy.RetryContext(this.getCurrentEndpoint(genericRequest)); int alternatives = distributor.getAmountOfAlternatives(ctx.endpoint); for(int i = 0; i < alternatives; ++i) { String activeEndpoint = distributor.getActiveEndpoint(ctx.endpoint); if (!ctx.invokedEndpoints.contains(activeEndpoint)) { ctx.invokedEndpoints.add(activeEndpoint); genericRequest.setEndpoint(activeEndpoint); try { GenericResponse resp = super.call(genericRequest); if (ctx.alternativeActivated) { LOG.debug("Activating status page polling!"); distributor.activatePolling(); } return resp; } catch (RetryNextEndpointException var9) { LOG.error("Unable to invoke endpoint [{}], activating next one.", activeEndpoint, var9); try { distributor.activateNextEndPoint(activeEndpoint); ctx.alternativeActivated = true; } catch (NoNextEndpointException var8) { LOG.error("Unable to activate alternative", var8); } ctx.lastException = var9; } } else { LOG.debug("Endpoint [{}] already invoked, skipping it.", activeEndpoint); } } if (EndpointDistributor.update()) { return this.invoke(genericRequest); } else { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_WS, ExceptionUtils.getRootCause(ctx.lastException), new Object[]{ExceptionUtils.getRootCauseMessage(ctx.lastException)}); } }