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:org.esupportail.portlet.filemanager.services.vfs.VfsAccessImpl.java

@Override
public List<JsTreeFile> getChildren(String path, SharedUserPortletParameters userParameters) {
    try {//from  ww w.j  a va  2 s  .c  om
        List<JsTreeFile> files = new ArrayList<JsTreeFile>();
        FileObject resource = cd(path, userParameters);
        FileObject[] children = resource.getChildren();
        if (children != null)
            for (FileObject child : children)
                if (!"imaginary".equals(child.getType().getName())
                        && (userParameters.isShowHiddenFiles() || !this.isFileHidden(child)))
                    files.add(resourceAsJsTreeFile(child, false, true, userParameters.isShowHiddenFiles()));
        return files;
    } catch (FileSystemException fse) {
        Throwable cause = ExceptionUtils.getCause(fse);
        if (cause != null && cause.getClass().equals(SftpException.class)) {
            SftpException sfe = (SftpException) cause;
            if (sfe.id == ChannelSftp.SSH_FX_PERMISSION_DENIED)
                throw new EsupStockPermissionDeniedException(sfe);
        }
        if (cause != null && cause.getClass().equals(JSchException.class)) {
            if ("session is down".equals(cause.getMessage())) {
                log.info("Session is down, we close all so that we can try to reopen a connection");
                throw new EsupStockLostSessionException((JSchException) cause);
            }
        }
        throw new EsupStockException(fse);
    }
}

From source file:ch.systemsx.cisd.openbis.generic.client.web.server.UploadServiceServlet.java

@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request,
        final HttpServletResponse response) throws Exception {
    try {//ww  w .ja va  2  s. c  om
        return super.handleRequestInternal(request, response);
    } catch (final Throwable th) {
        operationLog.error("Error handling request.", th);
        if (th instanceof Error) {
            throw (Error) th;
        } else {
            String msg = th.getMessage();
            if (StringUtils.isBlank(msg)) {
                msg = String.format("Error handling request: %s.", th.getClass().getName());
            }
            sendResponse(response, Message.createErrorMessage(msg).toXml());
            return null;
        }
    }
}

From source file:com.alliander.osgp.acceptancetests.deviceinstallation.StartDeviceTestSteps.java

@DomainStep("the start device test response")
public boolean thenTheResponseShouldContain() {
    LOGGER.info("THEN: the start device test response.");

    try {/* w  w  w  .ja v a2s  . c  o  m*/
        Assert.assertNotNull("Response should not be null", this.response);
        Assert.assertNull("Throwable should be null", this.throwable);
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }

    return true;
}

From source file:eu.scape_project.planning.application.BugReport.java

/**
 * Adds the provided throwable and session information to the messages list.
 * /* w ww.  j  a v  a 2s .  co  m*/
 * @param throwable
 *            the throwable
 * @param sessionId
 *            the current session ID
 * @param currentPage
 *            the current page
 * @param currentPlan
 *            the current plan
 */
public void addExeptionToMessages(Throwable throwable, String sessionId, String currentPage, Plan currentPlan) {

    String username = null;
    if (user != null) {
        username = user.getUsername();
    } else {
        username = "";
    }

    ErrorMessage em = new ErrorMessage(throwable.getClass().getCanonicalName(), throwable.getMessage(),
            sessionId, username, currentPage, currentPlan);
    messages.addErrorMessage(em);
    log.debug("Added Error to Messages array: " + throwable.getClass().getCanonicalName());
}

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

@DomainStep("the get set reboot response request is received")
public void whenTheGetSetRebootResultRequestIsReceived() {
    LOGGER.info("WHEN: \"the set reboot request is received\".");

    try {/* w  w w  .  j a va2 s .  c  o m*/
        this.response = this.adHocManagementEndpoint.getSetRebootResponse(ORGANISATION_ID,
                this.setRebootAsyncRequest);

    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        this.throwable = t;
    }
}

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

@DomainStep("the get firmware version request is received")
public void whenTheRequestIsReceived() {
    LOGGER.info("WHEN: the get firmware version request is received.");

    try {/*w  w w . ja  v a 2 s . c  o m*/
        this.asyncResponse = this.firmwareManagementEndpoint.getFirmwareVersion(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.firmwaremanagement.GetFirmwareVersionSteps.java

@DomainStep("the get firmware version response request is received")
public void whenTheGetFirmwareVersionResponseRequestIsReceived() {
    LOGGER.info("WHEN: \"the get firmware response request is received\".");

    try {/*from www  .j  a  v a 2  s.  c o  m*/
        this.response = this.firmwareManagementEndpoint.getGetFirmwareVersionResponse(ORGANISATION_ID,
                this.asyncRequest);
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        this.throwable = t;
    }
}

From source file:org.fcrepo.server.storage.DefaultExternalContentManager.java

/**
 * Initializes the Module based on configuration parameters. The
 * implementation of this method is dependent on the schema used to define
 * the parameter names for the role of/*  ww w.j  av a 2  s  . co m*/
 * <code>org.fcrepo.server.storage.DefaultExternalContentManager</code>.
 *
 * @throws ModuleInitializationException
 *         If initialization values are invalid or initialization fails for
 *         some other reason.
 */
@Override
public void initModule() throws ModuleInitializationException {
    try {
        Server s_server = getServer();
        m_userAgent = getParameter("userAgent");
        if (m_userAgent == null) {
            m_userAgent = "Fedora";
        }

        fedoraServerPort = s_server.getParameter("fedoraServerPort");
        fedoraServerHost = s_server.getParameter("fedoraServerHost");
        fedoraServerRedirectPort = s_server.getParameter("fedoraRedirectPort");

        m_httpconfig = s_server.getWebClientConfig();
        if (m_httpconfig.getUserAgent() == null) {
            m_httpconfig.setUserAgent(m_userAgent);
        }

        m_http = new WebClient(m_httpconfig);

    } catch (Throwable th) {
        throw new ModuleInitializationException("[DefaultExternalContentManager] "
                + "An external content manager " + "could not be instantiated. The underlying error was a "
                + th.getClass().getName() + "The message was \"" + th.getMessage() + "\".", getRole());
    }
}

From source file:com.idega.core.cache.filter.Filter.java

/**
 * Checks whether a throwable, its root cause if it is a {@link ServletException}, or its cause, if it is a
 * Chained Exception matches an entry in the exceptionsToLogDifferently list
 *
 * @param throwable/*from w  ww .  j  a v a  2  s  .c om*/
 * @return true if the class name of any of the throwables is found in the exceptions to log differently
 */
private boolean matches(Throwable throwable) {
    if (this.exceptionsToLogDifferently == null) {
        return false;
    }
    if (this.exceptionsToLogDifferently.indexOf(throwable.getClass().getName()) != -1) {
        return true;
    }
    if (throwable instanceof ServletException) {
        Throwable rootCause = (((ServletException) throwable).getRootCause());
        if (this.exceptionsToLogDifferently.indexOf(rootCause.getClass().getName()) != -1) {
            return true;
        }
    }
    if (throwable.getCause() != null) {
        Throwable cause = throwable.getCause();
        if (this.exceptionsToLogDifferently.indexOf(cause.getClass().getName()) != -1) {
            return true;
        }
    }
    return false;
}

From source file:com.alliander.osgp.acceptancetests.deviceinstallation.StopDeviceTestSteps.java

@DomainStep("an ovl stop device test message with result (.*) should be sent to the ovl out queue")
public boolean thenAnOvlStopDeviceTestMessage(final String result) {
    LOGGER.info("THEN: an ovl stop device test message with result {} should be sent to the ovl out queue.",
            result);/*from   w  ww . java 2s . com*/

    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;
}