List of usage examples for java.lang Throwable getLocalizedMessage
public String getLocalizedMessage()
From source file:org.eclipse.jubula.rc.common.commands.AbstractCapTestCommand.java
/** * Is called if the graphics component cannot be found. Logs the error and * sets the action error event into the message. * @param response The response message//from w ww . j a v a2 s . co m * @param e The exception. */ private void handleComponentNotFound(CAPTestResponseMessage response, Throwable e) { if (LOG.isWarnEnabled()) { LOG.warn(e.getLocalizedMessage(), e); } response.setTestErrorEvent(EventFactory.createComponentNotFoundErrorEvent()); }
From source file:com.github.capone.controller.discovery.DiscoveryListFragment.java
public void startDiscovery() { serviceLoader = new DiscoveryTask() { @Override//from w w w . ja va2s . c o m public void onProgressUpdate(Server... server) { if (adapter != null) { if (adapter.getPosition(server[0]) == -1) { adapter.add(server[0]); } } } @Override protected void onPostExecute(Throwable throwable) { if (throwable != null) { Toast.makeText(DiscoveryListFragment.this.getContext(), throwable.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } } }; serviceLoader.execute(); }
From source file:com.kii.sample.hellothingif.LoginFragment.java
@OnClick(R.id.buttonOnboard) void onOnboardClicked() { String username = mUsername.getText().toString(); String userPassword = mUserPassword.getText().toString(); String vendorThingID = mVendorThingID.getText().toString(); String thingPassword = mThingPassword.getText().toString(); ProgressDialogFragment.show(getActivity(), getFragmentManager(), R.string.progress_onboard); PromiseAPIWrapper api = new PromiseAPIWrapper(mAdm, null); mAdm.when(api.initializeThingIFAPI(getContext(), username, userPassword, vendorThingID, thingPassword)) .then(new DoneCallback<ThingIFAPI>() { @Override//from w w w . ja v a 2 s.c om public void onDone(ThingIFAPI api) { if (getActivity() == null) { return; } ProgressDialogFragment.close(getFragmentManager()); if (mListener != null) { mListener.onThingIFInitialized(api); } } }).fail(new FailCallback<Throwable>() { @Override public void onFail(final Throwable tr) { ProgressDialogFragment.close(getFragmentManager()); showToast("Failed to onboard the thing: " + tr.getLocalizedMessage()); } }); }
From source file:org.apache.cayenne.tools.DbGeneratorMojo.java
public void execute() throws MojoExecutionException, MojoFailureException { Log logger = new MavenLogger(this); Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger)); AdhocObjectFactory objectFactory = injector.getInstance(AdhocObjectFactory.class); logger.info(/*from w w w. j a v a2 s .c om*/ String.format("connection settings - [driver: %s, url: %s, username: %s]", driver, url, username)); logger.info(String.format( "generator options - [dropTables: %s, dropPK: %s, createTables: %s, createPK: %s, createFK: %s]", dropTables, dropPK, createTables, createPK, createFK)); try { final DbAdapter adapterInst = (adapter == null) ? (DbAdapter) objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName()) : (DbAdapter) objectFactory.newInstance(DbAdapter.class, adapter); // Load the data map and run the db generator. DataMap dataMap = loadDataMap(); DbGenerator generator = new DbGenerator(adapterInst, dataMap, NoopJdbcEventLogger.getInstance()); generator.setShouldCreateFKConstraints(createFK); generator.setShouldCreatePKSupport(createPK); generator.setShouldCreateTables(createTables); generator.setShouldDropPKSupport(dropPK); generator.setShouldDropTables(dropTables); // load driver taking custom CLASSPATH into account... DriverDataSource dataSource = new DriverDataSource((Driver) Class.forName(driver).newInstance(), url, username, password); generator.runGenerator(dataSource); } catch (Exception ex) { Throwable th = Util.unwindException(ex); String message = "Error generating database"; if (th.getLocalizedMessage() != null) { message += ": " + th.getLocalizedMessage(); } logger.error(message); throw new MojoExecutionException(message, th); } }
From source file:com.ben.gank.fragment.WebFragment.java
private void getIsCollect() { dataService.findBookmarkById(mObjectId).compose(this.<Bookmark>bindUntilEvent(FragmentEvent.PAUSE)) .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<Bookmark>() { @Override//w w w .java2 s . c o m public void onCompleted() { itemCollect.setEnabled(true); } @Override public void onError(Throwable e) { showSnackbar(e.getLocalizedMessage()); // Toast.makeText(getContext(), "onError", Toast.LENGTH_LONG).show(); Log.i("getIsCollect onError", e.getMessage()); } @Override public void onNext(Bookmark bookmark) { if (bookmark == null) { itemCollect.setIcon(R.drawable.ic_star_outline_grey600_24dp); isCollected = false; } else { itemCollect.setIcon(R.drawable.ic_star_grey600_24dp); isCollected = true; } } }); }
From source file:com.consol.citrus.admin.launcher.ProcessLauncherTest.java
private ProcessListener getProcessListener(final List<Boolean> callbacks) { // reset callbacks for (int i = 0; i < callbacks.size(); i++) { callbacks.set(i, false);//from www . ja v a2 s.com } return new ProcessListener() { public void onProcessStart(String processId) { System.out.println("Starting:" + processId + ", " + new Date()); callbacks.set(0, Boolean.TRUE); } public void onProcessSuccess(String processId) { System.out.println("Success:" + processId); callbacks.set(1, Boolean.TRUE); } public void onProcessFail(String processId, int exitCode) { System.err.println("Failed:" + processId + ", errorCode:" + exitCode); callbacks.set(2, Boolean.TRUE); } public void onProcessFail(String processId, Throwable e) { System.err.println("Failed:" + processId + ", ex:" + e.getLocalizedMessage()); e.printStackTrace(); callbacks.set(3, Boolean.TRUE); } public void onProcessOutput(String processId, String output) { //do nothing as activity was already printed } public void onProcessActivity(String processId, String output) { System.out.println(processId + ":" + output); } }; }
From source file:com.dataflowdeveloper.processors.process.NLPProcessor.java
@Override public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { FlowFile flowFile = session.get();//from w w w . j av a 2 s. c o m if (flowFile == null) { flowFile = session.create(); } try { flowFile.getAttributes(); service = new OpenNLPService(); String sentence = flowFile.getAttribute(ATTRIBUTE_INPUT_NAME); String sentence2 = context.getProperty(ATTRIBUTE_INPUT_NAME).evaluateAttributeExpressions(flowFile) .getValue(); if (sentence == null) { sentence = sentence2; } try { // if they pass in a sentence do that instead of flowfile if (sentence == null) { final AtomicReference<String> contentsRef = new AtomicReference<>(null); session.read(flowFile, new InputStreamCallback() { @Override public void process(final InputStream input) throws IOException { final String contents = IOUtils.toString(input, "UTF-8"); contentsRef.set(contents); } }); // use this as our text if (contentsRef.get() != null) { sentence = contentsRef.get(); } } List<PersonName> people = service.getPeople( context.getProperty(EXTRA_RESOURCE).evaluateAttributeExpressions(flowFile).getValue(), sentence); int count = 1; for (PersonName personName : people) { flowFile = session.putAttribute(flowFile, "nlp_name_" + count, personName.getName()); count++; } List<String> dates = service.getDates( context.getProperty(EXTRA_RESOURCE).evaluateAttributeExpressions(flowFile).getValue(), sentence); count = 1; for (String aDate : dates) { flowFile = session.putAttribute(flowFile, "nlp_date_" + count, aDate); count++; } List<Location> locations = service.getLocations( context.getProperty(EXTRA_RESOURCE).evaluateAttributeExpressions(flowFile).getValue(), sentence); count = 1; for (Location location : locations) { flowFile = session.putAttribute(flowFile, "nlp_location_" + count, location.getLocation()); count++; } } catch (Exception e) { throw new ProcessException(e); } session.transfer(flowFile, REL_SUCCESS); session.commit(); } catch (final Throwable t) { getLogger().error("Unable to process NLP Processor file " + t.getLocalizedMessage()); getLogger().error("{} failed to process due to {}; rolling back session", new Object[] { this, t }); throw t; } }
From source file:com.ebay.spine.WindowsWebDriverVNCProxy.java
private void prepareVM() { log.info("node restarting..."); int nbtry = 0; while (nbtry < 2) { nbtry++;/* ww w . j a v a 2 s . com*/ try { // start webdriver server. getVm().revertToSnapshot(snapshot); refreshNetwork(); log.info("VNC server started : " + VNC_SERVER); getVm().getVIXService().runProgramInGuest(null, VNC_SERVER, true); System.out.println( "reverted to " + snapshot + " and refreshed network.The ip is now " + getRemoteURL()); totalTestStarted = 0; totalTestFinished = 0; break; } catch (Throwable e) { log.error("error preparing the web driver client." + e.getMessage()); throw new GridException(e.getLocalizedMessage(), e); } } startWebDriver(seleniumPath); // make sure webdriver is responding before finishing the registration // process. int maxTries = 20; int tries = 0; while (!isAlive()) { tries++; if (tries >= maxTries) { throw new RuntimeException("Server didn't come up after " + tries + " tries."); } try { Thread.sleep(2000); } catch (InterruptedException e) { } } log.info("node restarted and ready"); super.hasRestarted(); System.out.println("PREPARE OK"); }
From source file:com.consol.citrus.admin.process.ProcessLauncherTest.java
private ProcessListener getProcessListener(final List<Boolean> callbacks) { // reset callbacks for (int i = 0; i < callbacks.size(); i++) { callbacks.set(i, false);/*from w ww . j a va2s . c o m*/ } return new ProcessListener() { public void onProcessStart(String processId) { System.out.println("Starting:" + processId + ", " + new Date()); callbacks.set(0, Boolean.TRUE); } public void onProcessSuccess(String processId) { System.out.println("Success:" + processId); callbacks.set(1, Boolean.TRUE); } public void onProcessFail(String processId, int exitCode) { System.err.println("Failed:" + processId + ", errorCode:" + exitCode); callbacks.set(2, Boolean.TRUE); } public void onProcessFail(String processId, Throwable e) { System.err.println("Failed:" + processId + ", ex:" + e.getLocalizedMessage()); log.error("Failed", e); callbacks.set(3, Boolean.TRUE); } public void onProcessOutput(String processId, String output) { //do nothing as activity was already printed } public void onProcessActivity(String processId, String output) { System.out.println(processId + ":" + output); } }; }
From source file:org.apache.cayenne.tools.DbImporterMojo.java
public void execute() throws MojoExecutionException, MojoFailureException { Log logger = new MavenLogger(this); DbImportConfiguration config = createConfig(logger); Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger), new DbImportModule()); DbImportConfigurationValidator validator = new DbImportConfigurationValidator(reverseEngineering, config, injector);/*from w w w . j ava2 s.c o m*/ try { validator.validate(); } catch (Exception ex) { throw new MojoExecutionException(ex.getMessage(), ex); } try { injector.getInstance(DbImportAction.class).execute(config); } catch (Exception ex) { Throwable th = Util.unwindException(ex); String message = "Error importing database schema"; if (th.getLocalizedMessage() != null) { message += ": " + th.getLocalizedMessage(); } getLog().error(message); throw new MojoExecutionException(message, th); } }