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:airlift.servlet.rest.RestfulSecurityContext.java

/**
 * Gets the user./*  w ww  .  j av  a2s  . co  m*/
 *
 * @param _id the _id
 * @return the user
 */
public AirliftUser getUser(String _id) {
    AirliftUser user = null;
    String id = (_id != null) ? _id.toLowerCase() : null;

    com.google.appengine.api.datastore.AsyncDatastoreService datastore = com.google.appengine.api.datastore.DatastoreServiceFactory
            .getAsyncDatastoreService();
    com.google.appengine.api.datastore.Key key = com.google.appengine.api.datastore.KeyFactory
            .createKey(getKind(), id);

    com.google.appengine.api.datastore.Entity entity = (com.google.appengine.api.datastore.Entity) getCachingContext()
            .get(key);

    if (entity == null) {
        try {
            entity = datastore.get(key).get();
            logInfo("Retrieved airlift user entity from datastore: " + entity.toString());
        } catch (Throwable t) {
            log.warning(t.toString());
            log.warning("unable to get entity of kind: " + getKind() + " from the datastore");
        }
    } else {
        logInfo("Cache hit on user entity of kind: " + getKind() + ".");
    }

    if (entity != null) {
        logInfo("Copy entity to user");
        user = copyEntityToAirliftUser(entity);
    }

    return user;
}

From source file:se.vgregion.javg.portlet.filter.PortletErrorHandlingFilter.java

@Override
public void doFilter(RenderRequest request, RenderResponse arg1, FilterChain arg2)
        throws IOException, PortletException {
    String nameSpace = arg1.getNamespace();

    if (request.getParameter("errorInActionPhase") != null) {
        // if the portlet threw an exception during the action phase we
        // won't go into the view phase
        Map<String, ?> userInfo = (Map<String, ?>) request.getAttribute(PortletRequest.USER_INFO);
        String userId = "";

        if (userInfo != null) {
            userId = (String) userInfo.get(PortletRequest.P3PUserInfos.USER_LOGIN_ID.toString());
        }/*www  . jav  a2  s.  co  m*/

        arg1.getWriter()
                .write(createTyckTillPopupLink(request.getParameter("errorInActionPhase"), userId, nameSpace));
    } else {
        try {
            // call next in line (either another filter or the portlet
            // itself)
            arg2.doFilter(request, arg1);
        } catch (Throwable e) {
            LOGGER.info("Exception caught in PortletErrorHandlingFilter", e);
            Map<String, ?> userInfo = (Map<String, ?>) request.getAttribute(PortletRequest.USER_INFO);
            String userId = "";
            if (userInfo != null) {
                userId = (String) userInfo.get(PortletRequest.P3PUserInfos.USER_LOGIN_ID.toString());
            }

            try {
                arg1.getWriter().write(createTyckTillPopupLink(e.toString(), userId, nameSpace));
            } catch (Throwable t) {
                LOGGER.error("Failed to create link", t);

            }
        }
    }
}

From source file:io.bitsquare.gui.util.BSFormatter.java

/**
 * Converts to a fiat with max. 2 decimal places. Last place gets rounded.
 * 0.234 -> 0.23/*from  ww w  . j  av  a2s.  c om*/
 * 0.235 -> 0.24
 *
 * @param input
 * @return
 */

public Fiat parseToFiatWithPrecision(String input, String currencyCode) {
    if (input != null && input.length() > 0) {
        try {
            return parseToFiat(
                    new BigDecimal(cleanInput(input)).setScale(2, BigDecimal.ROUND_HALF_UP).toString(),
                    currencyCode);
        } catch (Throwable t) {
            log.warn("Exception at parseToFiatWithPrecision: " + t.toString());
            return Fiat.valueOf(currencyCode, 0);
        }

    }
    return Fiat.valueOf(currencyCode, 0);
}

From source file:com.vmware.photon.controller.api.client.resource.TenantsApiTest.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);

    TenantsApi tenantsApi = new TenantsApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);

    tenantsApi.deleteAsync("foo", new FutureCallback<Task>() {
        @Override/*w  w  w  .  ja  v 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.vmware.photon.controller.api.client.resource.TenantsApiTest.java

@Test
public void testCreateResourceTicketAsync() 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);

    TenantsApi tenantsApi = new TenantsApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);

    tenantsApi.createResourceTicketAsync("foo", new ResourceTicketCreateSpec(), new FutureCallback<Task>() {
        @Override/*from  w  w  w . j  a v  a2s .  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.TenantsApiTest.java

@Test
public void testCreateProjectAsync() 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);

    TenantsApi tenantsApi = new TenantsApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);

    tenantsApi.createProjectAsync("foo", new ProjectCreateSpec(), new FutureCallback<Task>() {
        @Override/*  w  w  w. j a v  a  2s. 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.TenantsRestApiTest.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);

    TenantsApi tenantsApi = new TenantsRestApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);

    tenantsApi.deleteAsync("foo", new FutureCallback<Task>() {
        @Override//from w  w w . j a v  a2s. 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.vmware.photon.controller.api.client.resource.TenantsRestApiTest.java

@Test
public void testCreateResourceTicketAsync() 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);

    TenantsApi tenantsApi = new TenantsRestApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);

    tenantsApi.createResourceTicketAsync("foo", new ResourceTicketCreateSpec(), new FutureCallback<Task>() {
        @Override/*from  w ww .  j  a  v  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.vmware.photon.controller.api.client.resource.TenantsRestApiTest.java

@Test
public void testCreateProjectAsync() 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);

    TenantsApi tenantsApi = new TenantsRestApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);

    tenantsApi.createProjectAsync("foo", new ProjectCreateSpec(), new FutureCallback<Task>() {
        @Override/*from   w  w w.jav a  2s . 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));
}