List of usage examples for java.lang Exception getLocalizedMessage
public String getLocalizedMessage()
From source file:com.ratusapparatus.tapsaff.TapsAff.java
protected void onPostExecute(String feed) { ComponentName thisWidget = new ComponentName(context, TapsAff.class); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout); Log.i("tapsaffonPostExecuteFeed", feed); JSONObject jsonObj;// www . j av a 2 s . c o m try { jsonObj = new JSONObject(feed); /*for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); Log.i(TapsAff.class.getName(), jsonObject.getString("text")); }*/ String oanAff = jsonObj.get("taps").toString(); Integer itsClose = (Integer) jsonObj.get("temp_f"); if (itsClose >= TapsAff.tapsTemp - 5 && itsClose <= TapsAff.tapsTemp) views.setViewVisibility(R.id.bottom, View.VISIBLE); else views.setViewVisibility(R.id.bottom, View.GONE); String colour = "blue"; if (oanAff == "Aff") colour = "red"; String text = "taps" + " " + "<font color='" + colour + "'>" + oanAff + "</font>"; //textView.setText(, TextView.BufferType.SPANNABLE); views.setTextViewText(R.id.main, Html.fromHtml(text)); } catch (Exception e) { Log.i("tapsaffonPostExecuteException", e.getLocalizedMessage()); } appWidgetManager.updateAppWidget(thisWidget, views); }
From source file:com.splicemachine.derby.stream.function.FileFunction.java
/** * * Call Method for parsing the string into either a singleton List with a LocatedRow or * an empty list./* www. ja v a 2 s. c o m*/ * * @param s * @return * @throws Exception */ @Override public Iterator<LocatedRow> call(final String s) throws Exception { if (operationContext.isFailed()) return Collections.<LocatedRow>emptyList().iterator(); if (!initialized) { Reader reader = new StringReader(s); checkPreference(); tokenizer = new MutableCSVTokenizer(reader, preference); initialized = true; } try { tokenizer.setLine(s); List<String> read = tokenizer.read(); BooleanList quotedColumns = tokenizer.getQuotedColumns(); LocatedRow lr = call(read, quotedColumns); return lr == null ? Collections.<LocatedRow>emptyList().iterator() : new SingletonIterator(lr); } catch (Exception e) { if (operationContext.isPermissive()) { operationContext.recordBadRecord(e.getLocalizedMessage(), e); return Collections.<LocatedRow>emptyList().iterator(); } throw StandardException.plainWrapException(e); } }
From source file:org.brekka.phalanx.webservices.SoapExceptionResolver.java
protected String determineMessage(final Exception ex) { String localizedMessage = ex.getLocalizedMessage(); String faultString = StringUtils.isNotBlank(localizedMessage) ? localizedMessage : ex.toString(); return faultString; }
From source file:org.openmrs.module.radiologyapp.fragment.controller.RadiologyRequisitionFragmentController.java
public FragmentActionResult orderRadiology(@BindParams RadiologyRequisition requisition, @RequestParam("modality") String modality, UiSessionContext uiSessionContext, @SpringBean RadiologyService radiologyService, @SpringBean("messageSourceService") MessageSourceService messageSourceService, UiUtils ui, HttpServletRequest request) {/*from ww w .j a v a 2 s .c o m*/ if (requisition.getStudies().size() == 0) { throw new IllegalArgumentException(ui.message("radiologyapp.order.noStudiesSelected")); } // set provider and location if not specified if (requisition.getRequestedBy() == null) { requisition.setRequestedBy(uiSessionContext.getCurrentProvider()); } if (requisition.getRequestedFrom() == null) { requisition.setRequestedFrom(uiSessionContext.getSessionLocation()); } try { radiologyService.placeRadiologyRequisition(requisition); } catch (Exception e) { // TODO make this more user-friendly (but we never should get here) return new FailureResult(e.getLocalizedMessage()); } request.getSession().setAttribute(AppUiConstants.SESSION_ATTRIBUTE_INFO_MESSAGE, messageSourceService.getMessage("radiologyapp.task.order." + modality.toUpperCase() + ".success")); request.getSession().setAttribute(AppUiConstants.SESSION_ATTRIBUTE_TOAST_MESSAGE, "true"); return new SuccessResult(); }
From source file:com.mytwitter.retrofit.RetrofitErrorHandler.java
@Override public Throwable handleError(RetrofitError error) { logger.debug("error: " + error.getKind()); if (error.getKind().equals(RetrofitError.Kind.NETWORK)) { // Phone is not connected at all return new NoConnectivityException(context.getString(R.string.no_internet_connection)); }//from www .ja v a 2s . c om if (error.getKind().equals(RetrofitError.Kind.CONVERSION)) { // Web services usually return JSON, so the phone is probably trying to use mobile data without credit return new NoConnectivityException( context.getString(R.string.no_internet_connection_mobile_out_of_credit)); } Response response = error.getResponse(); String errorDescription = "Unknown Retrofit error"; if (response == null) { return error; } switch (response.getStatus()) { case HttpStatus.SC_BAD_REQUEST: // 404 returned from the server means there is no matching data errorDescription = error.getMessage().replace("400", ""); break; case HttpStatus.SC_UNAUTHORIZED: //return new UnauthorizedException(error); case HttpStatus.SC_NOT_FOUND: if (!TextUtils.isEmpty(error.getMessage())) { // 404 returned from the server means there is no matching data errorDescription = error.getMessage().replace("404", ""); } break; case HttpStatus.SC_INTERNAL_SERVER_ERROR: if (!TextUtils.isEmpty(error.getMessage())) { // 500 returned from the server means the server error errorDescription = error.getMessage().replace("500", ""); } break; case HttpStatus.SC_SERVICE_UNAVAILABLE: return new NoConnectivityException("Server is not responding"); default: try { errorDescription = context.getString(R.string.error_network_http_error, error.getResponse().getStatus()); } catch (Exception ex2) { logger.error("handleError: " + ex2.getLocalizedMessage()); errorDescription = context.getString(R.string.error_unknown); } break; } //return error; return new Exception(errorDescription); }
From source file:cz.zcu.kiv.eeg.mobile.base.ws.asynctask.CreateScenario.java
/** * Method, where scenario information is pushed to server in order to new scenario. * All heavy lifting is made here.//from www .j a va 2 s .c o m * * @param scenarios only one scenario is accepted - scenario to be uploaded * @return scenario stored */ @Override protected Scenario doInBackground(Scenario... scenarios) { SharedPreferences credentials = getCredentials(); String username = credentials.getString("username", null); String password = credentials.getString("password", null); String url = credentials.getString("url", null) + Values.SERVICE_SCENARIOS; setState(RUNNING, R.string.working_ws_create_scenario); HttpAuthentication authHeader = new HttpBasicAuthentication(username, password); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setAuthorization(authHeader); requestHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_XML)); SSLSimpleClientHttpRequestFactory factory = new SSLSimpleClientHttpRequestFactory(); //so files wont buffer in memory factory.setBufferRequestBody(false); // Create a new RestTemplate instance RestTemplate restTemplate = new RestTemplate(factory); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); restTemplate.getMessageConverters().add(new FormHttpMessageConverter()); restTemplate.getMessageConverters().add(new SimpleXmlHttpMessageConverter()); Scenario scenario = scenarios[0]; try { Log.d(TAG, url); FileSystemResource toBeUploadedFile = new FileSystemResource(scenario.getFilePath()); //due to multipart file, MultiValueMap is the simplest approach for performing the post request MultiValueMap<String, Object> form = new LinkedMultiValueMap<String, Object>(); form.add("scenarioName", scenario.getScenarioName()); form.add("researchGroupId", scenario.getResearchGroupId()); form.add("description", scenario.getDescription()); form.add("mimeType", scenario.getMimeType()); form.add("private", Boolean.toString(scenario.isPrivate())); form.add("file", toBeUploadedFile); HttpEntity<Object> entity = new HttpEntity<Object>(form, requestHeaders); // Make the network request ResponseEntity<Scenario> response = restTemplate.postForEntity(url, entity, Scenario.class); return response.getBody(); } catch (Exception e) { Log.e(TAG, e.getLocalizedMessage(), e); setState(ERROR, e); } finally { setState(DONE); } return null; }
From source file:com.cloudant.sync.datastore.encryption.KeyStorage.java
/** * Remove from the {@link SharedPreferences} a {@link KeyData} associated to the same * identifier used to//from w ww.j a v a 2s . c o m * create this storage. * <p/> * It will succeed if the data is deleted or if there is no data at all. * * @return true (success) or false (fail) */ public boolean clearEncryptionKeyData() { try { SharedPreferences.Editor editor = this.prefs.edit(); editor.remove(preferenceKey); editor.commit(); } catch (Exception e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); return false; } return true; }
From source file:com.mac.holdempoker.socket.HoldemEndpoint.java
@Override public void onError(WebSocket ws, Exception excptn) { System.out.println("ERROR"); System.out.println(excptn);/*from w w w .java2 s. co m*/ System.out.println(excptn.getLocalizedMessage()); System.out.println(excptn.getCause()); System.out.println(excptn.getMessage()); System.out.println(ws); }
From source file:tasly.greathealth.oms.web.delivery.soap.resources.impl.TaslyOmsPackingStatusUpdateServiceImpl.java
/** * ECC order packing status updated into OMS * * Packing status/*from w w w .j ava2s .c om*/ * Return nothing * * @param baseinfo * @param packingMessage * */ @Override @WebMethod @Oneway public void updateOrderStatus4Packing(final Baseinfo baseinfo, final Message packingMessage) { LOG.info("?ECC??..."); final long beginTime = System.currentTimeMillis(); final List<String> omsOrderIds = new ArrayList<String>(); List<String> packingFailedOrders = new ArrayList<String>(); // put all of these packing order id into a list; if (null != packingMessage && null != packingMessage.getOmsOrderIds()) { for (final String omsOrderId : packingMessage.getOmsOrderIds()) { omsOrderIds.add(omsOrderId); } } LOG.info("??? " + omsOrderIds.size()); // begin process all of these packing order status if (omsOrderIds.size() > 0) { try { packingFailedOrders = orderDeliveryStatusUpdateFacade.updateOrderStatus4Packing(omsOrderIds); LOG.info("???:" + (System.currentTimeMillis() - beginTime) / 1000f + " "); if (null != packingFailedOrders && packingFailedOrders.size() > 0) { LOG.error("???" + packingFailedOrders.size() + "??"); for (final String id : packingFailedOrders) { LOG.error(id); } } } catch (final Exception e) { LOG.error("??!"); LOG.error(e.getLocalizedMessage()); e.printStackTrace(); } } }
From source file:com.amazonaws.mturk.cmd.UpdateHITs.java
public HIT[] updateHITs(String successFile, String props) throws Exception { HITProperties hc = new HITProperties(props); // Output initializing message log.info("--[Initializing]----------"); log.info(" Success File: " + successFile); log.info(" Properties: " + props); log.info("--[Updating HITs]----------"); Date startTime = new Date(); log.info(" Start time: " + startTime); String[] hitIds = super.getFieldValuesFromFile(successFile, "hitid"); String[] hitTypeIds = super.getFieldValuesFromFile(successFile, "hittypeid"); log.info(" Input: " + hitIds.length + " hitids"); HITDataOutput success = new HITDataWriter(successFile + ".success"); HITDataOutput failure = null;//from ww w.j a v a2 s .c om success.setFieldNames(new String[] { "hitid", "hittypeid" }); String newHITTypeId; try { newHITTypeId = service.registerHITType(hc.getAutoApprovalDelay(), hc.getAssignmentDuration(), hc.getRewardAmount(), hc.getTitle(), hc.getKeywords(), hc.getDescription(), hc.getQualificationRequirements()); } catch (Exception e) { log.error("Failed to register new HITType: " + e.getLocalizedMessage(), e); return new HIT[0]; } log.info(" New HITTypeId: " + newHITTypeId); List<HIT> hits = new ArrayList<HIT>(hitIds.length); for (int i = 0; i < hitIds.length; i++) { try { HIT hit = service.getHIT(hitIds[i]); service.changeHITTypeOfHIT(hit.getHITId(), newHITTypeId); HashMap<String, String> good = new HashMap<String, String>(); good.put("hitid", hit.getHITId()); good.put("hittypeid", newHITTypeId); success.writeValues(good); log.info("Updated HIT #" + i + " (" + hit.getHITId() + ") to new HITTypeId " + newHITTypeId); hits.add(hit); } catch (Exception e) { if (failure == null) { failure = new HITDataWriter(successFile + ".failure"); failure.setFieldNames(new String[] { "hitid", "hittypeid" }); } HashMap<String, String> fail = new HashMap<String, String>(); fail.put("hitid", hitIds[i]); fail.put("hittypeid", hitTypeIds[i]); failure.writeValues(fail); log.info("Failed to update HIT #" + i + "(" + hitIds[i] + ") to new HITTypeId " + newHITTypeId + " Error message:" + e.getLocalizedMessage()); } } Date endTime = new Date(); log.info(" End time: " + endTime); log.info("--[Done Updating HITs]----------"); log.info(hitIds.length + " HITS were processed"); log.info(hits.size() + " HITS were updated"); if (hitIds.length != hits.size()) log.info(hitIds.length - hits.size() + " HITS could not be updated"); log.info(" Total load time: " + (endTime.getTime() - startTime.getTime()) / 1000 + " seconds."); return hits.toArray(new HIT[hits.size()]); }