List of usage examples for java.lang Exception getCause
public synchronized Throwable getCause()
From source file:com.thinkbiganalytics.nifi.rest.NifiRestTest2.java
public void testEvent() { try {/*from w w w. j a v a 2s.c om*/ ProcessGroupDTO dto = restClient.getProcessGroupByName("root", "jhim"); //ProcessGroupEntity entity= restClient.getProcessGroup("3813381f-2205-414c-bfcf-5900f45fcf601234",true,true); int i = 0; } catch (Exception e) { if (e instanceof NotFoundException) { int i = 0; } else if (e instanceof ProcessingException) { if (e.getCause() instanceof NoHttpResponseException) { //connection error } else if (e.getCause() instanceof HttpHostConnectException) { //connection error } } } }
From source file:com.nextdoor.bender.ipc.http.HttpTransportTest.java
@Test(expected = IOException.class) public void testIOException() throws Throwable { byte[] arr = "{".getBytes(); HttpClient client = getMockClientWithResponse(arr, ContentType.DEFAULT_BINARY, HttpStatus.SC_INTERNAL_SERVER_ERROR, false); doThrow(new IOException()).when(client).execute(any(HttpPost.class)); HttpTransport transport = new HttpTransport(client, "", true, 3, 1); try {//from w ww. j a v a 2 s. co m transport.sendBatch("foo".getBytes()); } catch (Exception e) { throw e.getCause().getCause(); } }
From source file:com.heren.turtle.server.service.impl.LisWebService.java
@Override public String getLisApply(String message) { this.logger.info("getLisApply receive mnis request message:\n" + message); try {//from w ww . j a v a 2 s . c om if (XmlUtils.isXml(message)) { Map<String, Object> params = XmlUtils.getMessage(message); Map<String, Object> queryMap; if (BooleanUtils.putMapBoolean(params, "test_no")) { queryMap = BooleanUtils.putMapBooleanList(params, "test_no"); } else { throw new LackElementException("can't be without the key of the parameters"); } List<Map<String, Object>> resultList = lisAgent.getLisApply(queryMap); String resultMessage = XmlUtils.createResultMessage(resultList); this.logger.info("successful operation"); this.logger.info("getLisApply result:" + resultMessage); return resultMessage; } else { this.logger.info(MessageConstant.formatFailed); return XmlUtils.errorMessage(MessageConstant.formatFailed); } } catch (Exception e) { this.logger.error("exception:" + e.getCause()); return XmlUtils.errorMessage(e.getMessage()); } }
From source file:simbio.se.sau.network.client.SauHttpClient.java
/** * Make a POST request//ww w . j a v a 2 s . c om * * @param url the Url to make the request * @param context the {@link Context} to codify the json * @param jsonParams the {@link JSONObject} to be codified * @since {@link API#Version_3_1_3} */ public void post(final String url, final Context context, final JSONObject jsonParams) { cachedKey = cacheManager.makeKey(url, jsonParams); postRunnable = new Runnable() { @Override public void run() { try { getAsyncHttpClient().post(context, url, new StringEntity(jsonParams.toString()), "application/json", SauHttpClient.this); } catch (Exception e) { onFailure(e.getCause(), ""); } } }; thread.start(); }
From source file:br.com.manish.ahy.web.BaseJSF.java
protected void treat(Exception e) { OopsException oe = null;/*ww w . j a v a 2 s . c om*/ if (e instanceof OopsException) { oe = (OopsException) e; } else if (e.getCause() instanceof OopsException) { oe = (OopsException) e.getCause(); } String msg = ""; if (oe != null) { msg = oe.getMessage(); msg = formatMsg(msg, oe.getAdditionalInformation()); log.warn("OopsException: " + oe.getMessage() + " - " + msg); } else { Throwable tmp = e; msg += tmp.getMessage() + "\n"; while (tmp.getCause() != null) { msg += tmp.getMessage() + "\n"; tmp = tmp.getCause(); } logException(e); } FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null)); }
From source file:org.easyj.rest.exceptions.UncaughtExceptionHandler.java
@Override public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {/*from w w w .j a v a 2 s .c o m*/ ModelAndView mav = new ModelAndView(); String exception = ""; Exception ex2 = ex; while (ex2 != null) { exception += "\n" + ex2.getClass().getSimpleName() + " - " + ex2.getMessage(); ex2 = (Exception) ex2.getCause(); } mav.setViewName(viewName); mav.addObject("status", UncaughtExceptionHandler.ERROR_STATUS); mav.addObject("exception", exception); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); logger.error("Uncaught Exception Error", ex); return mav; }
From source file:eu.liveGov.libraries.livegovtoolkit.helper.QuestionaireHelper.java
private void handleGetResponse(HttpResponse response) { if (response != null && response.getStatusLine().getStatusCode() == 200) { try {//from www . ja v a 2 s . c o m Gson gson = new Gson(); JsonReader jr = new JsonReader(new InputStreamReader(response.getEntity().getContent())); QuestionaireResponseObject result = gson.fromJson(jr, QuestionaireResponseObject.class); if (result.getStatus() == QuestionaireResponseObject.QUESTIONAIRE_SET) { updateQuestionaireListeners(result.getQuestionaire()); } else if (result.getStatus() == QuestionaireResponseObject.QUESTIONAIRE_RESULT_SET) { updateQuestionaireResultListeners(result.getQuestionaireResult()); } else if (result.getStatus() == QuestionaireResponseObject.BOTH_SET) { updateBothListeners(result.getQuestionaire(), result.getQuestionaireResult()); } else { // if the status is unknown, send a null object. updateQuestionaireListeners(null); } } catch (Exception e) { logger.error("webcallReady; Exception: {}", e.getCause()); updateQuestionaireListeners(null); } } else { if (response == null) { logger.error("webcallReady; No internet"); } else { logger.error("webcallReady; http statuscode: {}", response.getStatusLine().getStatusCode()); } updateQuestionaireListeners(null); } }
From source file:io.uengine.web.configuration.ConfigurationController.java
/** * ?? ? .//www.j a v a 2 s. c om */ @RequestMapping(value = "bundle", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public Response getBundle(final Locale locale) throws IOException { Response response = new Response(); try { Map map = Messages.toMap(locale); map.put("browser.language", locale.getLanguage()); map.put("browser.country", locale.getCountry()); map.put("browser.locale", locale.toString()); MultiValueMap headers = new HttpHeaders(); response.getMap().putAll(map); response.setSuccess(true); } catch (Exception ex) { response.getError().setMessage(ex.getMessage()); if (ex.getCause() != null) response.getError().setCause(ex.getCause().getMessage()); response.getError().setException(ExceptionUtils.getFullStackTrace(ex)); } return response; }
From source file:com.heren.turtle.server.service.impl.LisWebService.java
@Override public String lisReport(String message) { this.logger.info("lisReport receive mnis request message:\n" + message); try {//from w w w . j av a2 s .c o m if (XmlUtils.isXml(message)) { Map<String, Object> params = XmlUtils.getMessage(message); Map<String, Object> queryMap; if (BooleanUtils.putMapBoolean(params, "germ_or_normal")) { queryMap = BooleanUtils.putMapBooleanList(params, "test_no", "item_no", "print_order", "report_item_name", "report_item_code", "report_item_name2", "report_item_code2", "result", "units", "abnormal_indicator", "instrument_id", "send_time", "verified_time", "result_date_time", "result_doctor", "lower_limit", "upper_limit", "ref_range", "germ_or_normal"); } else { throw new LackElementException("can't be without the key of the parameters"); } Map<String, Object> resultMap = lisAgent.lisReport(queryMap, message); String resultMessage = XmlUtils.createResultMessage(resultMap); this.logger.info("successful operation"); this.logger.info("lisReport result:" + resultMessage); return resultMessage; } else { this.logger.info(MessageConstant.formatFailed); return XmlUtils.errorMessage(MessageConstant.formatFailed); } } catch (Exception e) { this.logger.error("exception:" + e.getCause()); return XmlUtils.errorMessage(e.getMessage()); } }
From source file:com.twitter.distributedlog.config.ConfigurationSubscription.java
private boolean fileNotFound(Exception ex) { return ex instanceof FileNotFoundException || ex.getCause() != null && ex.getCause() instanceof FileNotFoundException; }