List of usage examples for java.lang RuntimeException getMessage
public String getMessage()
From source file:com.vmware.o11n.plugin.powershell.model.generate.ScriptActionGenerator.java
public ScriptModule generateAction(IVSOFactoryClient factory, String actionName, String categoryName, String script) {/*from w ww. j ava2 s.com*/ Validate.notNull(factory, "Factory can not be null."); Validate.notEmpty(actionName, "Action name can not be null or empty."); Validate.notEmpty(categoryName, "Category name can not be null or empty."); ScriptModule module = null; try { ScriptModuleCategory category = factory.getScriptModuleCategoryForName(categoryName); Validate.notNull(category, "Unable to find category with name " + categoryName); /*Check if there is already action with the same name*/ Validate.isTrue(category.getScriptModuleWithName(actionName) == null, "Action with provided name already exists."); ScriptModuleBuilder builder = new ScriptModuleBuilder().setName(actionName) .setDescription("Auto generated.").setResultType(Constants.TYPE_POWER_SHELL_REMOTE_PS_OBJECT); // Add input params // Add system input params builder.addParameter(PARAM_HOST, "PowerShell:PowerShellHost"); builder.addParameter(PARAM_SESSIONID, "string"); script = extractParameters(script, builder); builder.setScript(generateActionContent(script)); module = builder.insert(categoryName, factory); } catch (RuntimeException exc) { log.warn(exc.getMessage()); throw (RuntimeException) exc; } catch (Exception exc) { String message = exc.getMessage(); if (message == null || message.length() == 0) { message = "Failed to create action for provided script."; } log.warn(message); throw new RuntimeException(message, exc); } return module; }
From source file:com.github.carlomicieli.rest.resources.ScalesResource.java
@DELETE @Path("/{scaleId}") public void delete(@PathParam("scaleId") long scaleId) { log.info("DELETE /scales"); try {/*w w w.j av a 2 s.c o m*/ scaleService.remove(new Scale(scaleId)); } catch (RuntimeException ex) { log.error(ex.getMessage()); throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); } }
From source file:com.braindrainpain.docker.httpsupport.HttpClientServiceTest.java
@Test public void testCheckConnectionThrowsIOExceptionOnExecuteMethodShouldThrowRuntimeException() throws IOException { when(httpClient.executeMethod(any(HttpMethod.class))).thenThrow(new IOException()); try {/*from ww w . j a va2 s .co m*/ httpClientService.checkConnection(URL); fail(); } catch (RuntimeException e) { Assert.assertEquals("Error connecting to: '" + URL + "'", e.getMessage()); } }
From source file:example.customers.integration.StoreIntegration.java
private void discoverByLocationLink() { try {/*from w w w .j a va 2 s.c om*/ URI storesUri = URI.create(env.getProperty("integration.stores.uri")); log.info("Trying to access the stores system at {}", storesUri); Traverson traverson = new Traverson(storesUri, MediaTypes.HAL_JSON); this.storesByLocationLink = traverson.follow("stores", "search", "by-location").asLink(); log.info("Found stores-by-location link pointing to {}.", storesByLocationLink.getHref()); } catch (RuntimeException o_O) { this.storesByLocationLink = null; log.info("Stores system unavailable. Got: ", o_O.getMessage()); } }
From source file:com.expedia.seiso.web.controller.ExceptionHandlerAdvice.java
@ExceptionHandler(RuntimeException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody//from w ww. j ava2 s . c om public ErrorObject handleRuntimeException(RuntimeException e, WebRequest request) { log.error("Internal server error", e); val fullMsg = e.getClass().getName() + ": " + e.getMessage(); return new ErrorObject(C.EC_INTERNAL_ERROR, fullMsg); }
From source file:com.github.carlomicieli.rest.resources.ScalesResource.java
@POST @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response post(ScaleRepresentation scaleRep) { log.info("POST /scales"); final Scale scale = scaleRep.getInner(); try {//w w w . j a v a 2s . c o m long id = scaleService.create(scale); // the response contains the ETag for the resource just created. return Response.created(URI.create(Long.toString(id))).tag(scaleRep.tag()).build(); } catch (RuntimeException ex) { log.error(ex.getMessage()); throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } }
From source file:com.github.carlomicieli.rest.resources.ScalesResource.java
@PUT @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response put(ScaleRepresentation scaleRep) { log.info("PUT /scales"); final Scale scale = scaleRep.getInner(); try {/*from ww w . jav a 2 s . co m*/ scaleService.save(scale); // the response contains the ETag for the resource just created. return Response.noContent().tag(scaleRep.tag()).build(); } catch (RuntimeException ex) { log.error(ex.getMessage()); throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } }
From source file:de.kaiserpfalzEdv.vaadin.PresentationHelper.java
@Subscribe public void navigateTo(NavigateToEvent event) { LOG.debug("Navigate to: {}", event); try {/* ww w . ja v a 2 s . c o m*/ UI.getCurrent().getNavigator().navigateTo(event.getPayload()); } catch (RuntimeException e) { LOG.error(e.getClass().getSimpleName() + " caught: " + e.getMessage(), e); NotificationPayload error = new NotificationPayload(e.getMessage()) .setCaption("error.navigation.generic-failure.caption"); error(new ErrorNotificationEvent(this, error)); } }
From source file:cs.rsa.ts14dist.client.StandardClientRequestHandler.java
@Override public LineType addLine(String user, String ts14Line) throws IOException { // Build the json request object JSONObject requestJson = CommandLanguage.createRequestObject(user, Constants.ADDLINE_REQUEST, ts14Line); LineType lineType = LineType.INVALID_LINE; if (ts14Line.length() > Constants.MAX_LINE_SIZE) { System.out.println("Line too long"); } else {/*w w w. ja va 2 s. c o m*/ // Compute an answer for the given added line LineTypeClassifierStrategy classifier = new BravoLineTypeClassifierStrategy(); lineType = classifier.classify(ts14Line); // if the line type is legal, compose a reply, and update // the database if (lineType != LineType.INVALID_LINE) { try { // send the request over the connector and retrieve the reply object JSONObject replyJson = requestAndAwaitReply(requestJson, Priority.HIGH); // no error, so extract the reply from the reply object // and cast it to its proper type - bit tedious as the // values is SOMETIMES long and SOMETIMES int depending // on the distributed or non-distributed case. String asString = replyJson.get(Constants.RETURNVALUE_KEY).toString(); int boxedIndex = Integer.parseInt(asString); lineType = LineType.values()[boxedIndex]; } catch (RuntimeException e) { System.out.println(e.getMessage()); } } } return lineType; }
From source file:com.fluidops.iwb.deepzoom.CXMLServlet.java
static void readImageCollectionFile(String collection) { InputStream stream = null;/*from www .jav a 2s. c o m*/ try { stream = new FileInputStream(collection); Document doc = null; doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(stream); XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); XPathExpression expr = xpath.compile("//I"); NodeList result = (NodeList) expr.evaluate(doc, XPathConstants.NODESET); for (int i = 0; i < result.getLength(); i++) { Node node = result.item(i); NamedNodeMap map = node.getAttributes(); String source = map.getNamedItem("Source").getNodeValue(); String id = map.getNamedItem("Id").getNodeValue(); source = source.substring("dzimages/".length(), source.lastIndexOf(".xml")); ids.put(source, id); } } catch (RuntimeException e) { logger.error(e.getMessage(), e); } catch (Exception e) { logger.error(e.getMessage(), e); } finally { IOUtils.closeQuietly(stream); } }