Example usage for java.lang RuntimeException toString

List of usage examples for java.lang RuntimeException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.orchestra.portale.controller.EditDeepeningPageController.java

@RequestMapping(value = "/editdpage", params = "name")
public ModelAndView editPoi(@RequestParam(value = "name") String name) {
    ModelAndView model = new ModelAndView("editdpageform");
    try {//from   www.j a va 2s .c  o  m
        DeepeningPage poi = pm.findDeepeningPageByName(name);
        model.addObject("nome", poi.getName());
        model.addObject("cat", poi.getCategories());
        model.addObject("id", poi.getId());

        for (AbstractPoiComponent comp : poi.getComponents()) {

            //associazione delle componenti al model tramite lo slug
            String slug = comp.slug();
            int index = slug.lastIndexOf(".");
            String cname = slug.substring(index + 1).replace("Component", "").toLowerCase();

            try {
                Class c = Class.forName(slug);
                model.addObject(cname, c.cast(comp));
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(PoiViewController.class.getName()).log(Level.SEVERE, null, ex);

            }

        }

        return model;
    } catch (RuntimeException e) {
        ModelAndView model2 = new ModelAndView("errorViewPoi");
        model2.addObject("err", "Errore impossibile trovare la paginda d'approfondimento: " + e.toString());
        return model2;
    }
}

From source file:io.wcm.caravan.pipeline.impl.JsonPipelineMergeTest.java

@Test
public void mergePipelineIntoNoObjectNode() {
    TestJsonPipelineExceptionHandler handler = new TestJsonPipelineExceptionHandler();
    // test failed merge into already existing property
    JsonPipeline a = newPipelineWithResponseBody("{a: 123}");
    JsonPipeline b = newPipelineWithResponseBody("{b: 456}").extract("b").merge(a).handleException(handler);

    // Check that JSON pipeline could not be merged into another JSON pipeline because another JSON pipeline does not contain ObjectNode
    JsonPipelineOutputException exception = new JsonPipelineOutputException(
            "Only pipelines with JSON *Objects* can be used as a target for a merge operation, but response data for GET(//testService/path)+EXTRACT(b) contained IntNode");
    b.getStringOutput().subscribe(new ExceptionExpectingObserver(exception));
    RuntimeException actualException = handler.getActualException();
    verifyNoMoreInteractions(cacheAdapter);
    assertEquals(exception.toString(), actualException.toString());
}

From source file:io.wcm.caravan.pipeline.impl.JsonPipelineMergeTest.java

@Test
public void mergeNoObjectNodePipelineIntoTargetNode() {
    TestJsonPipelineExceptionHandler handler = new TestJsonPipelineExceptionHandler();
    // test failed merge into already existing property
    JsonPipeline a = newPipelineWithResponseBody("{a : 123}").extract("a");
    JsonPipeline b = newPipelineWithResponseBody("{b: {b : 123}}").merge(a, "b").handleException(handler);

    // Check that JSON pipeline could not be merged into another JSON pipeline target node because it does not contain an Object node
    JsonPipelineOutputException exception = new JsonPipelineOutputException(
            "Only pipelines with JSON *Object* responses can be merged into an existing target property");
    b.getStringOutput().subscribe(new ExceptionExpectingObserver(exception));
    RuntimeException actualException = handler.getActualException();
    verifyNoMoreInteractions(cacheAdapter);
    assertEquals(exception.toString(), actualException.toString());
}

From source file:io.wcm.caravan.pipeline.impl.JsonPipelineMergeTest.java

@Test
public void mergePipelineIntoAlreadyExistingProperty() {
    TestJsonPipelineExceptionHandler handler = new TestJsonPipelineExceptionHandler();
    // test failed merge into already existing property
    JsonPipeline a = newPipelineWithResponseBody("{a : 123}");
    JsonPipeline b = newPipelineWithResponseBody("{b: {a : 456}}").merge(a, "b").handleException(handler);

    // Check that JSON pipeline could not be merged into another JSON pipeline target node because it does not contain an Object node
    JsonPipelineOutputException exception = new JsonPipelineOutputException(
            "Target pipeline GET(//testService/path) already has a property named a");
    b.getStringOutput().subscribe(new ExceptionExpectingObserver(exception));
    RuntimeException actualException = handler.getActualException();
    verifyNoMoreInteractions(cacheAdapter);
    assertEquals(exception.toString(), actualException.toString());
}

From source file:io.wcm.caravan.pipeline.impl.JsonPipelineMergeTest.java

@Test
public void mergePipelineIntoNonObjectChildNode() {
    TestJsonPipelineExceptionHandler handler = new TestJsonPipelineExceptionHandler();
    // test failed merge into already existing property
    JsonPipeline a = newPipelineWithResponseBody("{a: 123}");
    JsonPipeline b = newPipelineWithResponseBody("{b: 456}").merge(a, "b").handleException(handler);

    // Check that Json pipeline could not be merged into another Json pipeline because it try no merge ObjectNode into a primitive child node
    JsonPipelineOutputException exception = new JsonPipelineOutputException(
            "When merging two pipelines into the same target property, both most contain JSON *Object* responses");
    b.getStringOutput().subscribe(new ExceptionExpectingObserver(exception));
    RuntimeException actualException = handler.getActualException();
    verifyNoMoreInteractions(cacheAdapter);
    assertEquals(exception.toString(), actualException.toString());
}

From source file:com.physicaroid.pocketduino.cordova.PocketDuino.java

/**
 * hex?/*from   ww w.  j a  v a 2 s . c  o m*/
 */
private void uploadHexFile(CallbackContext callbackContext, JSONArray args) {
    try {
        String fileName = args.getString(0);
        Log.d(POCKETDUINO, "!!!--- " + fileName + " ---!!!");
        // upload()?3? callback ?????????
        // ???????????????
        mPhysicaloid.upload(Boards.POCKETDUINO, cordova.getActivity().getResources().getAssets().open(fileName),
                null);
        PluginResult dataResult = new PluginResult(PluginResult.Status.OK);
        dataResult.setKeepCallback(true);
        callbackContext.sendPluginResult(dataResult);
    } catch (RuntimeException e) {
        try {
            String json = "{\"message\":" + e.toString() + " }";
            JSONObject parameter = new JSONObject(json);
            PluginResult dataResult = new PluginResult(PluginResult.Status.ERROR, parameter);
            dataResult.setKeepCallback(true);
            callbackContext.sendPluginResult(dataResult);
        } catch (JSONException exc) {
            Log.e(POCKETDUINO, exc.toString());
        }
    } catch (IOException e) {
        try {
            String json = "{\"message\":" + e.toString() + " }";
            JSONObject parameter = new JSONObject(json);
            PluginResult dataResult = new PluginResult(PluginResult.Status.ERROR, parameter);
            dataResult.setKeepCallback(true);
            callbackContext.sendPluginResult(dataResult);
        } catch (JSONException exc) {
            Log.e(POCKETDUINO, exc.toString());
        }
    } catch (JSONException e) {
        try {
            String json = "{\"message\":" + e.toString() + " }";
            JSONObject parameter = new JSONObject(json);
            PluginResult dataResult = new PluginResult(PluginResult.Status.ERROR, parameter);
            dataResult.setKeepCallback(true);
            callbackContext.sendPluginResult(dataResult);
        } catch (JSONException exc) {
            Log.e(POCKETDUINO, exc.toString());
        }
    }
}

From source file:com.google.nigori.server.NigoriServlet.java

/**
 * Handle initial request from client and dispatch to appropriate handler or return error message.
 *//*from w w w.j a v a 2  s.c  om*/
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    try {
        addCorsHeaders(resp);
        // Subset of path managed by this servlet; e.g. if URI is "/nigori/get" and servlet path
        // is "/nigori, then we want to retrieve "get" as the request type
        int startIndex = req.getServletPath().length() + 1;
        String requestURI = req.getRequestURI();
        if (requestURI.length() <= startIndex) {
            ServletException s = new ServletException(HttpServletResponse.SC_BAD_REQUEST,
                    "No request type specified.\n" + supportedTypes + "\n");
            log.fine(s.toString());
            s.writeHttpResponse(resp);
            return;
        }
        String requestType = requestURI.substring(startIndex);
        String requestMimetype = req.getContentType();
        RequestHandlerType handlerType = new RequestHandlerType(requestMimetype, requestType);

        RequestHandler handler = handlers.get(handlerType);
        if (handler == null) {
            throw new ServletException(HttpServletResponse.SC_NOT_ACCEPTABLE,
                    "Unsupported request pair: " + handlerType + "\n" + supportedTypes + "\n");
        }
        try {
            handler.handle(req, resp);
        } catch (NotFoundException e) {
            ServletException s = new ServletException(HttpServletResponse.SC_NOT_FOUND,
                    e.getLocalizedMessage());
            log.fine(s.toString());
            s.writeHttpResponse(resp);
        } catch (UnauthorisedException e) {
            ServletException s = new ServletException(HttpServletResponse.SC_UNAUTHORIZED,
                    "Authorisation failed: " + e.getLocalizedMessage());
            log.warning(s.toString());
            s.writeHttpResponse(resp);
        } catch (IOException ioe) {
            throw new ServletException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    "Internal error sending data to client");
        } catch (MessageLibrary.JsonConversionException jce) {
            throw new ServletException(HttpServletResponse.SC_BAD_REQUEST,
                    "JSON format error: " + jce.getMessage());
        } catch (RuntimeException re) {
            log.severe(re.toString());
            throw new ServletException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, re.toString());
        }

    } catch (ServletException e) {
        log.severe(e.toString());
        e.writeHttpResponse(resp);
    }
}

From source file:org.apache.james.mailrepository.file.FileMailRepository.java

@Override
public Mail retrieve(String key) throws MessagingException {
    try {/*from ww  w  .j a v  a2 s .  com*/
        Mail mc;
        try {
            mc = (Mail) objectRepository.get(key);
        } catch (RuntimeException re) {
            StringBuilder exceptionBuffer = new StringBuilder(128);
            if (re.getCause() instanceof Error) {
                exceptionBuffer.append("Error when retrieving mail, not deleting: ").append(re.toString());
            } else {
                exceptionBuffer.append("Exception retrieving mail: ").append(re.toString())
                        .append(", so we're deleting it.");
                remove(key);
            }
            final String errorMessage = exceptionBuffer.toString();
            getLogger().warn(errorMessage);
            getLogger().debug(errorMessage, re);
            return null;
        }
        MimeMessageStreamRepositorySource source = new MimeMessageStreamRepositorySource(streamRepository,
                destination, key);
        mc.setMessage(new MimeMessageCopyOnWriteProxy(source));

        return mc;
    } catch (Exception me) {
        getLogger().error("Exception retrieving mail: " + me);
        throw new MessagingException("Exception while retrieving mail: " + me.getMessage(), me);
    }
}

From source file:org.openhab.binding.knx.internal.bus.KNXBinding.java

/**
 * Handles the given {@link ProcessEvent}. After finding the corresponding
 * Item (by iterating through all known group addresses) this Item is updated.
 * Each item is added to a special list to identify and avoid echo's in
 * the <code>receiveUpdate</code> and <code>receiveCommand</code> methods.  
 *  /*w w  w  .j  ava2 s.c om*/
 * @param e the {@link ProcessEvent} to handle.
 */
private void readFromKNX(ProcessEvent e) {
    try {
        GroupAddress destination = e.getDestination();
        byte[] asdu = e.getASDU();
        if (asdu.length == 0) {
            return;
        }
        String[] itemList = getItemNames(destination);
        if (itemList.length == 0) {
            logger.debug("Received telegram for unknown group address {}", destination.toString());
        }
        for (String itemName : itemList) {
            Iterable<Datapoint> datapoints = getDatapoints(itemName, destination);
            if (datapoints != null) {
                for (Datapoint datapoint : datapoints) {
                    Type type = getType(datapoint, asdu);
                    if (type != null) {
                        // we need to make sure that we won't send out this event to
                        // the knx bus again, when receiving it on the openHAB bus
                        ignoreEventList.add(itemName + type.toString());
                        logger.trace("Added event (item='{}', type='{}') to the ignore event list", itemName,
                                type.toString());

                        if (type instanceof Command && isCommandGA(destination)) {
                            eventPublisher.postCommand(itemName, (Command) type);
                        } else if (type instanceof State) {
                            eventPublisher.postUpdate(itemName, (State) type);
                        } else {
                            throw new IllegalClassException(
                                    "Cannot process datapoint of type " + type.toString());
                        }

                        logger.trace("Processed event (item='{}', type='{}', destination='{}')", itemName,
                                type.toString(), destination.toString());
                    } else {
                        final char[] hexCode = "0123456789ABCDEF".toCharArray();
                        StringBuilder sb = new StringBuilder(2 + asdu.length * 2);
                        sb.append("0x");
                        for (byte b : asdu) {
                            sb.append(hexCode[(b >> 4) & 0xF]);
                            sb.append(hexCode[(b & 0xF)]);
                        }

                        logger.debug(
                                "Ignoring KNX bus data: couldn't transform to an openHAB type (not supported). Destination='{}', datapoint='{}', data='{}'",
                                new Object[] { destination.toString(), datapoint.toString(), sb.toString() });
                    }
                }
            }
        }
    } catch (RuntimeException re) {
        logger.error("Error while receiving event from KNX bus: " + re.toString());
    }
}

From source file:org.nuxeo.runtime.model.impl.ComponentManagerImpl.java

@Override
public synchronized void register(RegistrationInfo regInfo) {
    RegistrationInfoImpl ri = (RegistrationInfoImpl) regInfo;
    ComponentName name = ri.getName();/*from  ww  w .  jav a 2s  .  c o m*/
    if (blacklist.contains(name.getName())) {
        log.warn("Component " + name.getName() + " was blacklisted. Ignoring.");
        return;
    }
    if (reg.contains(name)) {
        if (name.getName().startsWith("org.nuxeo.runtime.")) {
            // XXX we hide the fact that nuxeo-runtime bundles are
            // registered twice
            // TODO fix the root cause and remove this
            return;
        }
        handleError("Duplicate component name: " + name, null);
        return;
    }
    for (ComponentName n : ri.getAliases()) {
        if (reg.contains(n)) {
            handleError("Duplicate component name: " + n + " (alias for " + name + ")", null);
            return;
        }
    }

    ri.attach(this);

    try {
        log.info("Registering component: " + name);
        if (!reg.addComponent(ri)) {
            log.info("Registration delayed for component: " + name + ". Waiting for: "
                    + reg.getMissingDependencies(ri.getName()));
        }
    } catch (RuntimeException e) {
        // don't raise this exception,
        // we want to isolate component errors from other components
        handleError("Failed to register component: " + name + " (" + e.toString() + ')', e);
        return;
    }
}