List of usage examples for java.lang RuntimeException getLocalizedMessage
public String getLocalizedMessage()
From source file:com.ning.metrics.collector.endpoint.resources.ScribeEventRequestHandler.java
/** * Process an list of logs sent by the native Scribe Servers. This is the main interface with Scribe. * * @param logEntries list of logEntries to process * @return resultCode OK if everything went well, TRY_LATER otherwise */// ww w . j a v a 2 s . c o m @Override public ResultCode Log(final List<LogEntry> logEntries) { boolean success = false; for (final LogEntry entry : logEntries) { final EventStats eventStats = new EventStats(); if (entry.getCategory() == null) { log.info("Ignoring scribe entry with null category"); eventHandler.handleFailure(entry); // We don't want Scribe to try later if it sends messages we don't understand. success = true; continue; } else if (entry.getMessage() == null) { log.info("Ignoring scribe entry with null message"); eventHandler.handleFailure(entry); // We don't want Scribe to try later if it sends messages we don't understand. success = true; continue; } try { log.debug(String.format("Parsing log: %s", entry)); // Return a collection here: in case of Smile, we may can a bucket of events that overlaps on multiple // output directories final Collection<? extends Event> events = extractEvent(entry.getCategory(), entry.getMessage()); // We only record failure when collectors are falling over (rejecting) success = true; for (final Event event : events) { if (event != null) { eventStats.recordExtracted(); if (!eventHandler.processEvent(event, eventStats)) { success = false; } } else { eventHandler.handleFailure(entry); } } } catch (RuntimeException e) { log.info(String.format("Ignoring malformed entry [%s]: %s", entry, e.getLocalizedMessage())); eventHandler.handleFailure(entry); // We don't want Scribe to try later if it sends messages we don't understand. success = true; } catch (TException e) { log.info(String.format("Ignoring malformed Thrift [%s]: %s", entry, e.getLocalizedMessage())); eventHandler.handleFailure(entry); // We don't want Scribe to try later if it sends messages we don't understand. success = true; } catch (IOException e) { log.info(String.format("Ignoring malformed Smile [%s]: %s", entry, e.getLocalizedMessage())); eventHandler.handleFailure(entry); // We don't want Scribe to try later if it sends messages we don't understand. success = true; } } if (success) { return ResultCode.OK; } else { // We mainly come here if the collectors are falling over (rejected event) return ResultCode.TRY_LATER; } }
From source file:com.num.mobiperf.AccountSelector.java
/** Starts an authentication request */ public void authenticate() throws OperationCanceledException, AuthenticatorException, IOException { //Logger.i("AccountSelector.authenticate() running"); /* We only need to authenticate every AUTHENTICATE_PERIOD_MILLI milliseconds, during * which we can reuse the cookie. If authentication fails due to expired * authToken, the client of AccountSelector can call authImmedately() to request * authenticate() upon the next checkin *///from ww w .jav a 2 s. co m long authTimeLast = this.getLastAuthTime(); long timeSinceLastAuth = System.currentTimeMillis() - authTimeLast; if (!this.shouldAuthImmediately() && authTimeLast != 0 && (timeSinceLastAuth < AUTHENTICATE_PERIOD_MSEC)) { return; } //Logger.i("Authenticating. Last authentication is " + // timeSinceLastAuth / 1000 / 60 + " minutes ago. "); AccountManager accountManager = AccountManager.get(context.getApplicationContext()); if (this.authToken != null) { // There will be no effect on the token if it is still valid //Logger.i("Invalidating token"); accountManager.invalidateAuthToken(ACCOUNT_TYPE, this.authToken); } Account[] accounts = accountManager.getAccountsByType(ACCOUNT_TYPE); //Logger.i("Got " + accounts.length + " accounts"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.context); String selectedAccount = prefs.getString("PREF_KEY_SELECTED_ACCOUNT", null); final String defaultUserName = "Anonymous"; isAnonymous = true; if (selectedAccount != null && selectedAccount.equals(defaultUserName)) { return; } if (accounts != null && accounts.length > 0) { // Default account should be the Anonymous account Account accountToUse = accounts[accounts.length - 1]; if (!accounts[accounts.length - 1].name.equals(defaultUserName)) { for (Account account : accounts) { if (account.name.equals(defaultUserName)) { accountToUse = account; break; } } } if (selectedAccount != null) { for (Account account : accounts) { if (account.name.equals(selectedAccount)) { accountToUse = account; break; } } } isAnonymous = accountToUse.name.equals(defaultUserName); if (isAnonymous) { //Logger.d("Skipping authentication as account is " + defaultUserName); return; } // WHERE YOU GET TOKEN!!!!!! //Logger.i("Trying to get auth token for " + accountToUse); AccountManagerFuture<Bundle> future = accountManager.getAuthToken(accountToUse, "ah", false, new AccountManagerCallback<Bundle>() { public void run(AccountManagerFuture<Bundle> result) { //Logger.i("AccountManagerCallback invoked"); try { getAuthToken(result); } catch (RuntimeException e) { System.out.println("Failed to get authToken" + e.getLocalizedMessage()); //Logger.e("Failed to get authToken", e); /* TODO(Wenjie): May ask the user whether to quit the app nicely here if a number * of trials have been made and failed. Since Speedometer is basically useless * without checkin */ } } }, null); //Logger.i("AccountManager.getAuthToken returned " + future); } else { throw new RuntimeException("No google account found"); } }
From source file:controller.CLI.java
private String pivot(boolean dual) { try {// www .j a v a 2 s.c o m LP lp = lps.get(p - 1).pivot(dual); lps.add(p++, lp); redo = 0; if (dual) return Output.dual(lp, stdPrec); return Output.primal(lp, stdPrec); } catch (RuntimeException err) { return err.getLocalizedMessage(); } }
From source file:uk.ac.horizon.artcodes.camera.CameraView.java
private void createCamera() { if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) { for (int cameraId = 0; cameraId < Camera.getNumberOfCameras(); cameraId++) { try { Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(cameraId, info); if (info.facing == facing) { openCamera(cameraId); return; }/*from ww w . ja v a2 s . c o m*/ } catch (RuntimeException e) { Log.e("Scanner", "Failed to open scanner " + cameraId + ": " + e.getLocalizedMessage(), e); } } for (int cameraId = 0; cameraId < Camera.getNumberOfCameras(); cameraId++) { try { openCamera(cameraId); return; } catch (RuntimeException e) { Log.e("Scanner", "Failed to open scanner " + cameraId + ": " + e.getLocalizedMessage(), e); } } } }
From source file:org.solovyev.android.calculator.variables.EditVariableFragment.java
private boolean applyData() { try {//from w ww. j a v a 2 s . co m final CppVariable newVariable = CppVariable.builder(nameView.getText().toString()) .withId(isNewVariable() ? NO_ID : variable.id).withValue(valueView.getText().toString()) .withDescription(descriptionView.getText().toString()).build(); final IConstant oldVariable = isNewVariable() ? null : variablesRegistry.getById(variable.id); variablesRegistry.addOrUpdate(newVariable.toJsclConstant(), oldVariable); return true; } catch (RuntimeException e) { setError(valueLabel, e.getLocalizedMessage()); } return false; }
From source file:ru.codeinside.gses.webui.form.EForm.java
@Override public void attach() { ActivitiApp app = (ActivitiApp) getApplication(); hasAnyResult = false;/*from www .j av a2 s . co m*/ if (serial == null) { serial = app.nextId(); putFields(formValue.getPropertyValues()); } app.getForms().put(serial, form); VerticalLayout layout = (VerticalLayout) getLayout(); try { integration = createIntegration(); integration.setSizeFull(); integration.setImmediate(true); layout.setSizeFull(); layout.addComponent(integration); layout.setExpandRatio(integration, 1f); layout.setImmediate(true); integration.setErrorReceiver(new ErrorReceiver()); integration.setValueReceiver(new ValueReceiver()); } catch (RuntimeException e) { Logger.getLogger(getClass().getName()).log(Level.WARNING, " ", e); layout.addComponent(new Label( " " + e.getLocalizedMessage())); } super.attach(); }
From source file:org.kuali.rice.krad.uif.util.ObjectPropertyUtils.java
/** * Modify a property value./*from ww w . j av a2s . co m*/ * * <p> * Upon returning from this method, the property referred to by the provided bean and property * path will have been populated with property value provided. If the propertyValue does not * match the type of the indicated property, then type conversion will be attempted using * {@link PropertyEditorManager}. * </p> * * @param object The bean instance to initialize a property value for. * @param propertyPath A property path expression in the context of the bean. * @param propertyValue The value to populate value in the property referred to by the provided * bean and property path. * @param ignoreUnknown True if invalid property values should be ignored, false to throw a * RuntimeException if the property reference is invalid. * @see ObjectPathExpressionParser */ public static void setPropertyValue(Object object, String propertyPath, Object propertyValue, boolean ignoreUnknown) { try { setPropertyValue(object, propertyPath, propertyValue); } catch (RuntimeException e) { // only throw exception if they have indicated to not ignore unknown if (!ignoreUnknown) { throw e; } if (LOG.isTraceEnabled()) { LOG.trace("Ignoring exception thrown during setting of property '" + propertyPath + "': " + e.getLocalizedMessage()); } } }
From source file:ru.codeinside.gses.webui.form.JsonForm.java
@Override public void attach() { hasAnyResult = false;//from ww w. jav a 2s.c o m VerticalLayout layout = (VerticalLayout) getLayout(); try { integration = createIntegration(); layout.addComponent(integration); layout.setExpandRatio(integration, 1f); integration.setErrorReceiver(new ErrorReceiver()); integration.setValueReceiver(new ValueReceiver()); } catch (RuntimeException e) { Logger.getLogger(getClass().getName()).log(Level.WARNING, " ", e); layout.addComponent(new Label( " " + e.getLocalizedMessage())); } super.attach(); }
From source file:org.mc4j.ems.impl.jmx.connection.bean.attribute.DAttribute.java
/** * Updates the local value of this mbean from the server * <p/>/*from www . ja v a 2s.c om*/ * TODO we should not update to null on failure, but retain the last known */ public synchronized Object refresh() { loaded = true; Object newValue = null; try { MBeanServer server = bean.getConnectionProvider().getMBeanServer(); newValue = server.getAttribute(bean.getObjectName(), getName()); } catch (ReflectionException e) { supportedType = false; registerFailure(e); throw new EmsException("Could not load attribute value " + e.toString(), e); } catch (InstanceNotFoundException e) { registerFailure(e); throw new EmsException( "Could not load attribute value, bean instance not found " + bean.getObjectName().toString(), e); } catch (MBeanException e) { registerFailure(e); Throwable t = e.getTargetException(); if (t != null) throw new EmsException( "Could not load attribute value, target bean threw exception " + t.getLocalizedMessage(), t); else throw new EmsException("Could not load attribute value " + e.getLocalizedMessage(), e); } catch (AttributeNotFoundException e) { registerFailure(e); throw new EmsException("Could not load attribute value, attribute [" + getName() + "] not found", e); } catch (UndeclaredThrowableException e) { if (e.getUndeclaredThrowable() instanceof InvocationTargetException) { Throwable t = e.getCause(); if (t.getCause() instanceof NotSerializableException) { supportedType = false; registerFailure(t.getCause()); throw new EmsException("Could not load attribute value " + t.getLocalizedMessage(), t.getCause()); } else throw new EmsException("Could not load attribute value " + t.getLocalizedMessage(), t); } throw new EmsException("Could not load attribute value " + e.getLocalizedMessage(), e); } catch (RuntimeException re) { supportedType = false; // TODO GH: Figure this one out // Getting weblogic.management.NoAccessRuntimeException on wl9 registerFailure(re); throw new EmsException("Could not load attribute value " + re.getLocalizedMessage(), re); } catch (NoClassDefFoundError ncdfe) { supportedType = false; registerFailure(ncdfe); throw new EmsException("Could not load attribute value " + ncdfe.getLocalizedMessage(), ncdfe); } catch (Throwable t) { throw new EmsException("Could not load attribute value " + t.getLocalizedMessage(), t); } alterValue(newValue); return newValue; }
From source file:org.openehealth.coala.beans.PatientBean.java
/** * Anchor point to trigger a real search within the coala-communication * layer./*from w ww . j ava2 s . c o m*/ * * @return Always returns an empty string. */ public String search() { FacesContext fc = FacesContext.getCurrentInstance(); String messages = fc.getApplication().getMessageBundle(); Locale locale = new Locale(localeHandler.getLocale()); ResourceBundle bundle = ResourceBundle.getBundle(messages, locale); //Clean ConsentBean consentBean.cleanForNewPatientSearch(); patientsResList = null; try { String givenNameCharsetChecked = checkAndFixWrongCharset(givenName); String lastNameCharsetChecked = checkAndFixWrongCharset(lastName); // generate FindPatientQuery FindPatientQuery findPatientQuery = new FindPatientQuery(patientID, givenNameCharsetChecked, lastNameCharsetChecked, birthdate); LOG.info("Preparing pdqv2 queries against PXS: \n" + findPatientQuery.toString()); long start = System.currentTimeMillis(); // perform query against PXS finally FindPatientResult findPatientResult = pxsQueryService.findPatients(findPatientQuery, sortParameter); long end = System.currentTimeMillis(); LOG.info("PXS pdqv2 query took " + (end - start) + " ms."); // process results if (findPatientResult != null && findPatientResult.getPatients().size() != 0) { patientsResList = new ArrayList<Patient>(); // all the other dynamically queried patients patientsResList.addAll(findPatientResult.getPatients()); setPatients(new ListDataModel<Patient>(patientsResList)); /* * cleaning up the old values of the UIInput fields */ cleanOutdatedViewState(); /* * resetting all consents which are outdated from now on within * the consent bean */ consentBean.setConsents(new ListDataModel<PatientConsent>()); initialSearchState = false; } else { cleanOutdatedViewState(); setPatients(new ListDataModel<Patient>()); FacesMessage msg = new FacesMessage(bundle.getString("errors.noPatientFound")); msg.setSeverity(FacesMessage.SEVERITY_INFO); fc.addMessage(fc.getViewRoot().findComponent("patientResultPanel").getClientId(), msg); LOG.warn("PDQ did not result in any hits. FindPatientResult was NULL...!"); } } catch (ServiceParameterException spe) { /* * if invalid parameters were given - which should not happen due to * earlier validation, we just set an empty result list */ setPatients(new ListDataModel<Patient>()); } catch (RuntimeException rt) { LOG.error(rt.getLocalizedMessage(), rt); } /* * returning an empty string as no navigation rule/case is associated * here */ return ""; }