Example usage for java.lang Throwable getClass

List of usage examples for java.lang Throwable getClass

Introduction

In this page you can find the example usage for java.lang Throwable getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.alliander.osgp.acceptancetests.adhocmanagement.ResumeScheduleSteps.java

@DomainStep("the resume schedule response request is received")
public void whenTheResumeScheduleResponseRequestIsReceived() {
    LOGGER.info("WHEN: \"the resume schedule response request is received\".");

    try {/*from w  ww  .  jav a2 s .  c om*/
        this.response = this.adHocManagementEndpoint.getResumeScheduleResponse(
                this.organisation.getOrganisationIdentification(), this.resumeScheduleAsyncRequest);
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        this.throwable = t;
    }
}

From source file:org.brekka.phalanx.webservices.SoapExceptionResolver.java

protected XmlObject prepareFaultDetail(final MessageContext messageContext, final String faultName,
        final SchemaType schemaType, final Throwable ex) throws Exception {

    XmlObject faultDocument = XmlBeans.getContextTypeLoader().newInstance(schemaType,
            XmlOptions.maskNull(null));/*from w  w  w.  ja  va  2s .c o m*/
    OperationFault faultType = prepareFaultType(faultName, faultDocument);

    ErrorCode code = PhalanxErrorCode.CP500;
    String message = "An unexpected error (" + ex.getClass().getSimpleName() + ")";
    if (ex instanceof ErrorCoded) {
        code = ((ErrorCoded) ex).getErrorCode();
        if (ex instanceof BaseException) {
            BaseException be = (BaseException) ex;
            message = format(be.getMessage(), (Object[]) be.getMessageArgs());
        } else if (ex instanceof BaseCheckedException) {
            BaseCheckedException bce = (BaseCheckedException) ex;
            message = format(bce.getMessage(), (Object[]) bce.getMessageArgs());
        } else {
            message = ex.getMessage();
        }
    } else if (ex instanceof ValidationFailureException) {
        code = PhalanxErrorCode.CP501;
        if (ex.getCause() != null) {
            message = ex.getCause().getMessage();
        }
    }
    faultType.setCode(code.toString());
    faultType.setMessage(message);

    return faultDocument;
}

From source file:de.tudarmstadt.lt.ltbot.postprocessor.DecesiveValuePrioritizer.java

@Override
protected void innerProcess(CrawlURI uri) throws InterruptedException {
    // CrawlURI is a candidate Uri which has to be scheduled according our priority
    synchronized (_lck) {
        double value = 0d;
        try {/*w  w w  .  j  a v  a 2s . c o  m*/
            value = getValueFromViaURI(uri);
            double oldvalue = getValueFromCurrentURI(uri);
            if (oldvalue <= value) // URI was already processed and value was equal to or lower than the current via url
                return;
        } catch (Throwable t) {
            for (int i = 1; t != null && i < 10; i++) {
                LOG.log(Level.WARNING,
                        String.format("Failed to get decisive value from extra info: (%d-%s:%s).", i,
                                t.getClass().getName(), t.getMessage()),
                        t);
                t = t.getCause();
            }
            return;
        }

        int schedulingConstants_priority = getPriorityAsSchedulingDirective(value);
        if (uri.getFullVia().isSeed() && uri.getLastHop().equals(Hop.REFER.getHopString()))
            schedulingConstants_priority = SchedulingConstants.HIGHEST;

        if (schedulingConstants_priority < 0) {
            _count_reject++;
            uri.setFetchStatus(S_OUT_OF_SCOPE); // this will not consider the url for further processing // TODO: there must be a better solution, maybe extend org.archive.crawler.prefetch.FrontierPreparer or org.archive.crawler.prefetch.CandidateScoper
        }

        uri.setSchedulingDirective(schedulingConstants_priority);
        if (schedulingConstants_priority >= 0)
            _assignment_counts[schedulingConstants_priority]++;
        LOG.finest(String.format("Assigned scheduling directive %d to %s.", schedulingConstants_priority,
                uri.toString()));
        // lower values have higher precedence, i.e. higher priority
        int cost = 255;
        if (schedulingConstants_priority == 0)
            cost = 1;
        else if (schedulingConstants_priority > 0)
            cost = getPrecedenceCost(value);
        uri.setHolderCost(cost);
        uri.setPrecedence(cost);
        LOG.finest(String.format("Assigned precedence cost %d to %s.", cost, uri.toString()));
        try {
            uri.getExtraInfo().put(SharedConstants.EXTRA_INFO_ASSIGNED_SCHEDULING_DIRECTIVE,
                    schedulingConstants_priority);
            uri.getExtraInfo().put(SharedConstants.EXTRA_INFO_ASSIGNED_COST_PRECEDENCE, cost);
            uri.getExtraInfo().put(SharedConstants.EXTRA_INFO_PERPLEXITY_VIA, String.format("%012g", value));
        } catch (Throwable t) {
            for (int i = 1; t != null && i < 10; i++) {
                LOG.log(Level.WARNING, String.format("Failed to add extra information to uri %s: (%d-%s:%s).",
                        uri.toString(), i, t.getClass().getName(), t.getMessage()), t);
                t = t.getCause();
            }
        }
    }
}

From source file:com.alliander.osgp.acceptancetests.firmwaremanagement.UpdateFirmwareSteps.java

@DomainStep("an ovl update firmware message with result (.*) should be sent to the ovl out queue")
public boolean thenAnOvlUpdateFirmwareMessage(final String result) {
    LOGGER.info("THEN: an ovl update firmware message with result {} should be sent to the ovl out queue.",
            result);//from  w w w .  ja va 2  s .  co m

    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.firmwaremanagement.UpdateFirmwareSteps.java

@DomainStep("an update firmware oslp message is sent to device (.*) with firmwareName (.*) and firmwareDomain (.*) should be (.*)")
public boolean thenAnUpdateFirmwareOslpMessageShouldBeSent(final String device, final String firmwareName,
        final String firmwareDomain, final Boolean isMessageSent) {
    LOGGER.info(/*from  ww  w. j  a v a 2s.  co  m*/
            "THEN: an update firmware oslp message is sent to device {} with firmwareName {} and firmwareDomain {} should be {}.",
            device, firmwareName, firmwareDomain, isMessageSent);

    final int count = isMessageSent ? 1 : 0;

    try {
        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 update firmware request.",
                    this.oslpRequest.getPayloadMessage().hasUpdateFirmwareRequest());
        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.aol.advertising.qiao.injector.file.AbstractFileReader.java

private boolean setPosition(long pos) {
    try {/*from w w  w .  ja v  a 2s  .co m*/
        readPosition.set(pos);
        return true;
    } catch (Throwable e) {
        logger.warn("position.set failed: " + e.getClass().getSimpleName() + ": " + e.getMessage());

    }

    return false;
}

From source file:com.alliander.osgp.acceptancetests.firmwaremanagement.UpdateFirmwareSteps.java

@DomainStep("the update firmware response request should return a firmware response with result (.*) and description (.*)")
public boolean thenTheUpdateFirmwareResponseRequestShouldReturnAGetFirmwareVersionResponse(final String result,
        final String description) {
    LOGGER.info(//  ww  w.  j a v  a 2 s. co m
            "THEN: \"the update firmware response request should return a firmware response with result {} and description {}",
            result, description);

    try {
        if ("NOT_OK".equals(result)) {
            Assert.assertNull("Set Schedule Response should be null", this.response);
            Assert.assertNotNull("Throwable should not be null", this.throwable);
            Assert.assertTrue("Throwable should contain a validation exception",
                    this.throwable.getCause() instanceof ValidationException);
        } else {

            Assert.assertNotNull("Response should not be null", this.response);

            final String expected = result.equals("NULL") ? null : result;
            final String actual = this.response.getResult().toString();

            Assert.assertTrue("Invalid result, found: " + actual + " , expected: " + expected,
                    (actual == null && expected == null) || 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.ResumeScheduleSteps.java

@DomainStep("an ovl resume schedule message with result (.*) and description (.*) should be sent to the ovl out queue")
public boolean thenAnOvlResumeScheduleMessageShouldBeSent(final String result, final String description) {
    LOGGER.info(// w  w w  .j  a  v a 2s .  c  o m
            "THEN: \"an ovl resume schedule 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;
}

From source file:be.wegenenverkeer.common.resteasy.exception.ExceptionUtil.java

/**
 * Return the cause exception.//from w w w  .j ava2  s .  c o m
 *
 * @param exc exception to get message for
 * @return cause exception if any
 */
private Throwable getCause(Throwable exc) {
    Throwable cause = exc.getCause();
    // use the roundabout way to figure out if there is a cause exception if none found easily
    // some classes, like EJBException need to be java 1.3 compatible and have a getCausedByException method
    if (cause == null) {
        Class clazz = exc.getClass();
        try {
            Method method = clazz.getMethod("getCausedByException");
            cause = (Throwable) method.invoke(exc);
        } catch (Exception ex) {
            cause = null; /*ignore*/
        }
    }
    return cause;
}

From source file:com.alliander.osgp.acceptancetests.adhocmanagement.ResumeScheduleSteps.java

@DomainStep("a resume schedule oslp message is sent to device (.*) should be (.*)")
public boolean thenAnOslpMessageShouldBeSent(final String device, final Boolean isMessageSent) {
    LOGGER.info("THEN: \"a resume schedule oslp message is sent to device {} should be {}.\"", device,
            isMessageSent);// www.j  ava  2s.co  m

    final int count = isMessageSent ? 1 : 0;

    try {
        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 resume schedule request.",
                    this.oslpRequest.getPayloadMessage().hasResumeScheduleRequest());
        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}