Example usage for java.lang Throwable toString

List of usage examples for java.lang Throwable toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.google.cloud.hadoop.util.LogUtil.java

/**
 * Logs a debug message.// w w w  .j a v  a  2  s .c o m
 *
 * @param message Message to log.
 * @param t Throwable to log.
 */
public synchronized void debug(String message, Throwable t) {
    if (log.isDebugEnabled()) {
        debug("%s\n%s\n%s", message, t.toString(), Throwables.getStackTraceAsString(t));
    }
}

From source file:com.google.cloud.hadoop.util.LogUtil.java

/**
 * Logs an error message./*from w w  w  . ja  va2s .  co  m*/
 *
 * @param message Message to log.
 * @param t Throwable to log.
 */
public synchronized void error(String message, Throwable t) {
    if (log.isErrorEnabled()) {
        error("%s\n%s\n%s", message, t.toString(), Throwables.getStackTraceAsString(t));
    }
}

From source file:com.vmware.photon.controller.api.client.resource.DisksApiTest.java

@Test
public void testGetDiskAsync() throws IOException, InterruptedException {
    final PersistentDisk persistentDisk = new PersistentDisk();
    persistentDisk.setId("persistentDisk");

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(persistentDisk);

    setupMocks(serializedTask, HttpStatus.SC_OK);

    DisksApi disksApi = new DisksApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);

    disksApi.getDiskAsync("disk1", new FutureCallback<PersistentDisk>() {
        @Override/*from   w  w w . j a v  a  2  s. c o  m*/
        public void onSuccess(@Nullable PersistentDisk result) {
            assertEquals(result, persistentDisk);
            latch.countDown();
        }

        @Override
        public void onFailure(Throwable t) {
            fail(t.toString());
            latch.countDown();
        }
    });

    assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true));
}

From source file:com.vmware.photon.controller.api.client.resource.DisksRestApiTest.java

@Test
public void testGetDiskAsync() throws IOException, InterruptedException {
    final PersistentDisk persistentDisk = new PersistentDisk();
    persistentDisk.setId("persistentDisk");

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(persistentDisk);

    setupMocks(serializedTask, HttpStatus.SC_OK);

    DisksApi disksApi = new DisksRestApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);

    disksApi.getDiskAsync("disk1", new FutureCallback<PersistentDisk>() {
        @Override// w w  w.j  av  a2  s  . co  m
        public void onSuccess(@Nullable PersistentDisk result) {
            assertEquals(result, persistentDisk);
            latch.countDown();
        }

        @Override
        public void onFailure(Throwable t) {
            fail(t.toString());
            latch.countDown();
        }
    });

    assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true));
}

From source file:com.vmware.photon.controller.clustermanager.testtool.TestRunner.java

public List<TestStats> run() throws Exception {
    List<TestStats> statsList = new ArrayList<>();
    for (int i = 0; i < arguments.getClusterCount(); i++) {
        TestStats stats = new TestStats();

        try {/* w w  w. j  av a  2s.  c o m*/
            // Create the Cluster
            String clusterId = createCluster(stats);

            // Wait for the Cluster to be Ready
            waitForReady(clusterId, stats);
        } catch (Throwable ex) {
            logger.error(ex.toString());
        } finally {

            // Delete the cluster.
            cleanupClusters();
        }

        statsList.add(stats);
    }

    return statsList;
}

From source file:edu.utah.further.mdr.impl.service.uml.XmiParser11Impl.java

/**
 * @param results//  w ww .j  a va  2  s. com
 * @return
 * @throws XMLStreamException 
 * @throws XQException
 */
@Override
protected UmlModel parseResults(final XMLStreamReader results) throws XMLStreamException {
    final UmlModel model = (UmlModel) (new UmlElementBuilder("MODEL_ROOT", "UML Model", ElementType.MODEL)
            .build());

    if (results.hasNext()) {
        final Element dts = getRootElement(results);
        final NodeList elements = dts.getChildNodes();
        for (int i = 0; i < elements.getLength(); i++) {
            try {
                final UmlElement vd = new UmlElementBuilder((Element) elements.item(i)).build();
                model.addChild(vd);
            } catch (final Throwable e) {
                final String message = e.getMessage();
                addMessage(Severity.ERROR,
                        StringUtils.isBlank(message) ? "Failed to build UmlElement: " + e.toString() : message);
            }
        }
    } else {
        addMessage(Severity.ERROR, "xquery did not return a result set");
    }
    return model;
}

From source file:com.vmware.photon.controller.api.client.resource.DisksApiTest.java

@Test
public void testDeleteAsync() throws IOException, InterruptedException {
    final Task responseTask = new Task();
    responseTask.setId("12345");
    responseTask.setState("QUEUED");
    responseTask.setQueuedTime(Date.from(Instant.now()));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(responseTask);

    setupMocks(serializedTask, HttpStatus.SC_CREATED);

    DisksApi disksApi = new DisksApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);

    disksApi.deleteAsync("persistentDisk", new FutureCallback<Task>() {
        @Override/* ww  w. j a va 2  s . com*/
        public void onSuccess(@Nullable Task result) {
            assertEquals(result, responseTask);
            latch.countDown();
        }

        @Override
        public void onFailure(Throwable t) {
            fail(t.toString());
            latch.countDown();
        }
    });

    assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true));
    ;
}

From source file:com.vmware.photon.controller.api.client.resource.DisksRestApiTest.java

@Test
public void testDeleteAsync() throws IOException, InterruptedException {
    final Task responseTask = new Task();
    responseTask.setId("12345");
    responseTask.setState("QUEUED");
    responseTask.setQueuedTime(Date.from(Instant.now()));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(responseTask);

    setupMocks(serializedTask, HttpStatus.SC_CREATED);

    DisksApi disksApi = new DisksRestApi(restClient);
    final CountDownLatch latch = new CountDownLatch(1);

    disksApi.deleteAsync("persistentDisk", new FutureCallback<Task>() {
        @Override/*from  w w  w .  j av a  2 s. c o  m*/
        public void onSuccess(@Nullable Task result) {
            assertEquals(result, responseTask);
            latch.countDown();
        }

        @Override
        public void onFailure(Throwable t) {
            fail(t.toString());
            latch.countDown();
        }
    });

    assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true));
    ;
}

From source file:com.fdt.sdl.admin.ui.action.UploadAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws IOException, ServletException {
    if (!SecurityUtil.isAdminUser(request))
        return (mapping.findForward("welcome"));

    ActionMessages messages = new ActionMessages();
    ActionMessages errors = new ActionMessages();

    if (FileUpload.isMultipartContent(request)) {
        try {//from  w w  w.  j  ava 2 s.  co  m
            //read old dataset values
            ServerConfiguration sc = ServerConfiguration.getServerConfiguration();
            ArrayList<DatasetConfiguration> old_dcs = ServerConfiguration.getDatasetConfigurations();
            Map<String, Long> oldModifiedTimes = new HashMap<String, Long>(old_dcs.size());
            for (DatasetConfiguration old_dc : old_dcs) {
                oldModifiedTimes.put(old_dc.getName(), old_dc.getConfigFile().lastModified());
            }

            DiskFileUpload upload = new DiskFileUpload();
            upload.setSizeMax(10 * 1024 * 1024);
            List items = upload.parseRequest(request);
            Iterator iter = items.iterator();
            while (iter.hasNext()) {
                FileItem item = (FileItem) iter.next();
                if (item.isFormField()) {
                } else {
                    String fileName = (new File(item.getName())).getName();
                    if (fileName.endsWith(".zip")) {
                        try {
                            extractZip(item.getInputStream());
                        } catch (Exception ee) {
                            logger.error("exception for zip:" + ee);
                            ee.printStackTrace();
                        }
                    }
                }
            }
            messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("action.uploadFiles.success"));
            saveMessages(request, messages);

            //merge old values into the new data set
            if (sc.getIsMergingOldDatasetValues()) {
                ArrayList<DatasetConfiguration> new_dcs = ServerConfiguration.getDatasetConfigurations();
                for (DatasetConfiguration new_dc : new_dcs) {
                    if (oldModifiedTimes.get(new_dc.getName()) != null
                            && new_dc.getConfigFile().lastModified() > oldModifiedTimes.get(new_dc.getName())) {
                        for (DatasetConfiguration old_dc : old_dcs) {
                            if (new_dc.getName() == old_dc.getName()) {
                                new_dc.merge(old_dc);
                                new_dc.save();
                                break;
                            }
                        }
                    }
                }
            }

            if (sc.getAllowedLicenseLevel() > 0) {
                //reload from the disk
                ArrayList<DatasetConfiguration> dcs = ServerConfiguration.getDatasetConfigurations();
                for (DatasetConfiguration dc : dcs) {
                    try {
                        SchedulerTool.scheduleIndexingJob(dc);
                    } catch (Throwable t) {
                        logger.info("Failed to schedule for " + dc.getName() + ": " + t.toString());
                    }
                }
            }

            return mapping.findForward("continue");
        } catch (Exception e) {
            errors.add("error", new ActionMessage("action.uploadFiles.error"));
            saveErrors(request, errors);
            return mapping.findForward("continue");
        }
    } else { // from other page
        //
    }

    return mapping.findForward("continue");
}

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

@DomainStep("the find recent devices request should return an empty owner exception")
public boolean thenTheFindRecentDevicesRequestShouldReturnAnEmptyOwnerException() {
    LOGGER.info("THEN: \"the find recent devices request should return an empty owner exception\".");

    try {/*from w w w.java  2 s.c o m*/
        verify(this.organisationRepositoryMock, times(0)).findByOrganisationIdentification(OWNER_EMPTY);
        verifyNoMoreInteractions(this.organisationRepositoryMock);

        verify(this.deviceRepositoryMock, times(0)).findRecentDevices(any(Organisation.class), any(Date.class));
        verifyNoMoreInteractions(this.deviceRepositoryMock);
    } catch (final Throwable t) {
        LOGGER.error("Exception: {}", t.toString());
        return false;
    }

    return this.throwable != null && this.throwable.getCause() instanceof ValidationException;
}