List of usage examples for java.lang Throwable getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.nesscomputing.jersey.exceptions.GuiceProvisionExceptionMapper.java
@Override public Response toResponse(final ProvisionException exception) { final Collection<Message> messages = exception.getErrorMessages(); Throwable cause = null; if (CollectionUtils.isNotEmpty(messages)) { for (Message message : messages) { cause = message.getCause();/*w ww . j a va 2 s .co m*/ if (cause != null) { break; } } } if (cause != null) { LOG.trace("Mapping %s", cause.getClass().getSimpleName()); final ExceptionMapper<Throwable> mapper = find(cause.getClass()); if (mapper != null) { return mapper.toResponse(cause); } } // Since this is not handled by any mappers, let's complain loudly. LOG.error(exception, "Did not find a mapper to handle exception type %s wrapped in ProvisionException", cause != null ? cause.getClass() : "<null>"); final Map<String, String> response = ImmutableMap.of("code", Status.INTERNAL_SERVER_ERROR.toString(), // XXX: this feels a tad like it violates encapsulation, but any other solution drags in tc-tracking as a dependency. "trace", ObjectUtils.toString(MDC.get("track")), "message", ((cause != null) ? Objects.firstNonNull(cause.getMessage(), "unknown") : "unknown")); return Response.status(Status.INTERNAL_SERVER_ERROR).entity(response).type(MediaType.APPLICATION_JSON_TYPE) .build(); }
From source file:com.alliander.osgp.acceptancetests.deviceinstallation.StopDeviceTestSteps.java
@DomainStep("a stop device test oslp message is sent to device (.*) should be (.*)") public boolean thenAStopDeviceTestOslpMessageShouldBeSent(final String device, final Boolean isMessageSent) { LOGGER.info("THEN: a stop device test oslp message is sent to device should be {}.", isMessageSent); final int count = isMessageSent ? 1 : 0; try {//from w w w . j a v a2s . c o m final ArgumentCaptor<OslpEnvelope> argument = ArgumentCaptor.forClass(OslpEnvelope.class); verify(this.channelMock, timeout(10000).times(count)).write(argument.capture()); if (isMessageSent) { this.oslpRequest = argument.getValue(); Assert.assertTrue("Message should contain stop device test request.", this.oslpRequest.getPayloadMessage().hasStopSelfTestRequest()); } } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:com.alliander.osgp.acceptancetests.firmwaremanagement.GetFirmwareVersionSteps.java
@DomainStep("the get firmware version response should contain firmware version (.*)") public boolean thenTheResponseShouldContain(final String firmwareVersion) { LOGGER.info("THEN: the get firmware version response should return {}.", firmwareVersion); try {/* ww w.jav a 2s . c o m*/ Assert.assertNotNull("Response should not be null", this.response); Assert.assertNull("Throwable should be null", this.throwable); Assert.assertEquals("Firmware version should equal expected value", firmwareVersion, this.response.getFirmwareVersion()); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:com.alliander.osgp.acceptancetests.deviceinstallation.StartDeviceTestSteps.java
@DomainStep("an ovl start device test message with result (.*) should be sent to the ovl out queue") public boolean thenAnOvlStartDeviceTestMessage(final String result) { LOGGER.info("THEN: an ovl start device test message with result {} should be sent to the ovl out queue.", result);//from w w w. j a va2 s . c om try { final ArgumentCaptor<ResponseMessage> argument = ArgumentCaptor.forClass(ResponseMessage.class); verify(this.webServiceResponseMessageSenderMock, timeout(10000).times(1)).send(argument.capture()); final String expected = result.equals("NULL") ? null : result; final String actual = argument.getValue().getResult().getValue(); Assert.assertTrue("Invalid result, found: " + actual + " , expected: " + expected, actual.equals(expected)); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:com.alliander.osgp.acceptancetests.adhocmanagement.SetTransitionSteps.java
@DomainStep("the set transition request is received") public void whenTheSetTransitionRequestIsReceived() { LOGGER.info("WHEN: the set transition request is received."); try {//from w w w. ja v a 2 s . c o m this.setTransitionAsyncResponse = this.adHocManagementEndpoint.setTransition(ORGANISATION_ID, this.request); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); this.throwable = t; } }
From source file:com.alliander.osgp.acceptancetests.deviceinstallation.StartDeviceTestSteps.java
@DomainStep("a start device test oslp message is sent to device (.*) should be (.*)") public boolean thenAStartDeviceTestOslpMessageShouldBeSent(final String device, final Boolean isMessageSent) { LOGGER.info("THEN: a start device test oslp message is sent to device should be {}.", isMessageSent); final int count = isMessageSent ? 1 : 0; try {//from w ww .j a va 2s . c om final ArgumentCaptor<OslpEnvelope> argument = ArgumentCaptor.forClass(OslpEnvelope.class); verify(this.channelMock, timeout(10000).times(count)).write(argument.capture()); if (isMessageSent) { this.oslpRequest = argument.getValue(); Assert.assertTrue("Message should contain start device test request.", this.oslpRequest.getPayloadMessage().hasStartSelfTestRequest()); } } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:de.knowwe.core.kdom.rendering.RenderResult.java
public RenderResult appendException(Throwable e) { appendException("Exception while rendering: " + e.getClass().getSimpleName() + (e.getMessage() == null ? "" : ": " + e.getMessage()), e); return this; }
From source file:com.alliander.osgp.acceptancetests.adhocmanagement.SetTransitionSteps.java
@DomainStep("the get set transition response request is received") public void whenTheGetSetTransitionResultRequestIsReceived() { LOGGER.info("WHEN: \"the set transition request is received\"."); try {//from w w w . j av a 2 s. co m this.response = this.adHocManagementEndpoint.getSetTransitionResponse(ORGANISATION_ID, this.setTransitionAsyncRequest); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); this.throwable = t; } }
From source file:com.alliander.osgp.acceptancetests.adhocmanagement.SetRebootSteps.java
@DomainStep("a set reboot oslp message is sent to the device should be (.*)") public boolean thenAnOslpMessageShouldBeSent(final Boolean isMessageSent) { LOGGER.info("THEN: a set reboot oslp message is sent to the device should be {}.", isMessageSent); final int count = isMessageSent ? 1 : 0; try {/*ww w .ja v a2 s. c o m*/ final ArgumentCaptor<OslpEnvelope> argument = ArgumentCaptor.forClass(OslpEnvelope.class); verify(this.channelMock, timeout(10000).times(count)).write(argument.capture()); if (isMessageSent) { this.oslpRequest = argument.getValue(); Assert.assertTrue("Message should contain set reboot request.", this.oslpRequest.getPayloadMessage().hasSetRebootRequest()); } } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }
From source file:com.alliander.osgp.acceptancetests.adhocmanagement.SetRebootSteps.java
@DomainStep("an ovl set reboot result message with result (.*) and description (.*) should be sent to the ovl out queue") public boolean thenAnOvlSetRebootResultMessageShouldBeSentToTheOvlOutQueue(final String result, final String description) { LOGGER.info(/* w ww. j a v a 2 s. c o m*/ "THEN: \"an ovl set reboot result message with result [{}] and description [{}] should be sent to the ovl out queue\".", result, description); try { final ArgumentCaptor<ResponseMessage> argument = ArgumentCaptor.forClass(ResponseMessage.class); verify(this.webServiceResponseMessageSenderMock, timeout(10000).times(1)).send(argument.capture()); final String expected = result.equals("NULL") ? null : result; final String actual = argument.getValue().getResult().getValue(); Assert.assertTrue("Invalid result, found: " + actual + " , expected: " + expected, actual.equals(expected)); } catch (final Throwable t) { LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage()); return false; } return true; }