List of usage examples for java.lang Exception getLocalizedMessage
public String getLocalizedMessage()
From source file:org.openmrs.module.providermanagement.fragment.controller.PatientEditFragmentController.java
public FragmentActionResult removeProviders(@RequestParam(value = "patient", required = true) Patient patient, @RequestParam(value = "relationshipType", required = true) RelationshipType relationshipType, @RequestParam(value = "providers", required = true) List<Person> providers) { try {//w w w .ja v a 2 s . c om for (Person provider : providers) { Context.getService(ProviderManagementService.class).unassignPatientFromProvider(patient, provider, relationshipType); } return new SuccessResult(); } catch (Exception e) { return new FailureResult(e.getLocalizedMessage()); } }
From source file:cn.com.inhand.devicenetworks.ap.mq.rabbitmq.TaskNotificationConsumer.java
public void listen(String message) { try {//from w w w. jav a2 s . co m DNMessage msg = parser.unwrap(message.getBytes()); if (msg != null) { Parameter param = msg.getParameter("id"); if (param != null) { String id = param.getValue(); WebSocketSession ws = this.cinfo.getWssn(id); if (ws != null) { ws.sendMessage(new TextMessage(message)); } else { //???Websocket AP?AP?AP??? //? // List list = new ArrayList(); // list.add(new Parameter("result","30005")); // list.add(new Parameter("reason","The asset is offline.")); // DNMessage ack = new DNMessage(msg.getName(),"response",msg.getTxid(),list); // // logger.info("The asset["+asset_id+"] is not online, return a offline ack to source. msg="+ack.toString()); // System.out.println("The asset["+asset_id+"] is not online, return a offline ack to source. msg="+ack.toString()); // //?rabbitmq rpc // //-------------------------------- } } else { //?? } } } catch (Exception e) { logger.warning(e.getLocalizedMessage()); } }
From source file:org.neo4j.ogm.drivers.http.transaction.HttpTransaction.java
@Override public void rollback() { try {// w w w. j ava 2 s.com if (transactionManager.canRollback()) { HttpDelete request = new HttpDelete(url); request.setHeader(new BasicHeader("X-WRITE", driver.readOnly() ? "0" : "1")); driver.executeHttpRequest(request); } } catch (Exception e) { LOGGER.warn(e.getLocalizedMessage()); } finally { super.rollback(); // must always be done to keep extension depth correct } }
From source file:com.liferay.ide.theme.core.util.BuildHelper.java
/** * Utility method to recursively delete a directory. * * @param dir//from ww w . j a v a 2 s. com * a directory * @param monitor * a progress monitor, or <code>null</code> if progress reporting and cancellation are not desired * @return a possibly-empty array of error and warning status */ public static IStatus[] deleteDirectory(File dir, IProgressMonitor monitor) { if (!dir.exists() || !dir.isDirectory()) return new IStatus[] { new Status(IStatus.ERROR, ThemeCore.PLUGIN_ID, 0, NLS.bind(Messages.errorNotADirectory, dir.getAbsolutePath()), null) }; List<IStatus> status = new ArrayList<IStatus>(2); try { File[] files = dir.listFiles(); int size = files.length; monitor = ProgressUtil.getMonitorFor(monitor); monitor.beginTask(NLS.bind(Messages.deletingTask, new String[] { dir.getAbsolutePath() }), size * 10); // cycle through files boolean deleteCurrent = true; for (int i = 0; i < size; i++) { File current = files[i]; if (current.isFile()) { if (!current.delete()) { status.add(new Status(IStatus.ERROR, ThemeCore.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, files[i].getAbsolutePath()), null)); deleteCurrent = false; } monitor.worked(10); } else if (current.isDirectory()) { monitor.subTask(NLS.bind(Messages.deletingTask, new String[] { current.getAbsolutePath() })); IStatus[] stat = deleteDirectory(current, ProgressUtil.getSubMonitorFor(monitor, 10)); if (stat != null && stat.length > 0) { deleteCurrent = false; addArrayToList(status, stat); } } } if (deleteCurrent && !dir.delete()) status.add(new Status(IStatus.ERROR, ThemeCore.PLUGIN_ID, 0, NLS.bind(Messages.errorDeleting, dir.getAbsolutePath()), null)); monitor.done(); } catch (Exception e) { ThemeCore.logError("Error deleting directory " + dir.getAbsolutePath(), e); //$NON-NLS-1$ status.add(new Status(IStatus.ERROR, ThemeCore.PLUGIN_ID, 0, e.getLocalizedMessage(), null)); } IStatus[] stat = new IStatus[status.size()]; status.toArray(stat); return stat; }
From source file:org.neo4j.ogm.persistence.authentication.AuthenticatingDriverTest.java
@Test public void testAuthorizedDriver() { session = new SessionFactory(driver, "dummy").openSession(); try (Transaction ignored = session.beginTransaction()) { assertThat(ignored).isNotNull(); } catch (Exception rpe) { fail("'" + rpe.getLocalizedMessage() + "' was not expected here"); }/*from w w w. j a va 2 s . co m*/ }
From source file:com.chatwingsdk.parsers.EventParserImpl.java
public Event parse(String json) throws JSONException { LogUtils.v(json);//from w w w . j a v a2 s. c o m JSONObject root = new JSONObject(json); String event = root.getString("event"); Class<? extends Params> c = getParamsClass(event); if (c == null) { throw new JSONException("Can't identify the event: " + event); } try { Params params = new Gson().fromJson(root.getJSONObject("params").toString(), c); return new Event(event, params); } catch (Exception ex) { throw new JSONException(ex.getLocalizedMessage()); } }
From source file:com.chatwing.whitelabel.parsers.EventParserImpl.java
public Event parse(String json) throws JSONException { JSONObject root = new JSONObject(json); String event = root.getString("event"); Class<? extends Params> c = getParamsClass(event); if (c == null) { throw new JSONException("Can't identify the event: " + event); }//from w w w .j a v a 2 s .c o m try { Params params = new Gson().fromJson(root.getJSONObject("params").toString(), c); return new Event(event, params); } catch (Exception ex) { throw new JSONException(ex.getLocalizedMessage()); } catch (IncompatibleClassChangeError ex) { throw new JSONException(ex.getLocalizedMessage()); } }
From source file:com.mc.printer.model.layout.ws.WebSender.java
public <T extends Object> T getForObject(String url, Class<T> responseType) throws RestClientException { try {//ww w. ja v a 2s.c om T obj = super.getForObject(url, responseType); return obj; } catch (Exception e) { throw new RestClientException("" + e.getLocalizedMessage()); } }
From source file:com.mc.printer.model.layout.ws.WebSender.java
public URI postForLocation(String url, Object request) throws RestClientException { try {//from w ww .ja v a 2 s. com URI uri = super.postForLocation(url, request); return uri; } catch (Exception e) { throw new RestClientException("" + e.getLocalizedMessage()); } }
From source file:com.mc.printer.model.layout.ws.WebSender.java
public <T extends Object> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType) throws RestClientException { try {/*from w ww . ja v a 2s .c o m*/ ResponseEntity<T> res = super.exchange(url, method, requestEntity, responseType); return res; } catch (Exception e) { throw new RestClientException("" + e.getLocalizedMessage()); } }