List of usage examples for java.lang Throwable toString
public String toString()
From source file:com.cisco.oss.foundation.message.AbstractRabbitMQConcurrentMessageHandler.java
public void onException(Message message, Throwable throwable) { LOGGER.error("Problem handling message: {}. error is: {}", message, throwable.toString(), throwable); if (messageIdentifier != null) { String identifier = messageIdentifier.getIdentifier(message); if (StringUtils.isNotEmpty(identifier)) { onWorkIdentifierMap.remove(identifier); }/* ww w. j av a 2s.co m*/ } }
From source file:sample.server.NativeGemFireServer.java
private void run(String[] args) { try {//from w ww . ja v a2s . co m writeStringTo(newGemFireLogFile("stdout"), "Before"); registerShutdownHook(addCacheServer(createRegion(gemfireCache(gemfireProperties(applicationName()))))); writeStringTo(newGemFireLogFile("stdout"), "After"); } catch (Throwable e) { writeStringTo(newGemFireLogFile("stderr"), e.toString()); } }
From source file:com.espirit.moddev.cli.exception.ExceptionHandler.java
/** * Log the given {@link java.lang.Throwable}. * If the -e switch is set, the full stack trace will be logged. See {@link com.espirit.moddev.cli.configuration.GlobalConfig#isError()}. * * @param error the error to be logged// w w w . jav a2 s .co m */ private void logException(final Throwable error) { if (argumentsContains("-e")) { LOGGER.error(error.toString(), error); } else { final Throwable rootCause = ExceptionUtils.getRootCause(error); if (rootCause != null) { LOGGER.error("{}\nError reason: {}", error.getMessage(), rootCause); } else { LOGGER.error("{}", error.getMessage()); } if (!arguments.isEmpty()) { LOGGER.info("See '" + appName + " help {}' for more information on a specific command.", arguments.stream() .filter(s -> ("import".equals(s) || "export".equals(s) || s.indexOf("store") != -1) && !"help".equals(s)) .reduce("", (s1, s2) -> s1 + " " + s2)); } } }
From source file:com.juick.android.JASocketClient.java
public boolean connect(String host, int port) { try {// ww w. j av a2 s. co m log("JASocketClient:" + name + ": new"); sock = new Socket(); sock.setSoTimeout(60000); // 1 minute timeout; to check missing pongs and drop connection sock.connect(new InetSocketAddress(host, port)); is = sock.getInputStream(); os = sock.getOutputStream(); log("connected"); return true; } catch (Throwable e) { log("connect:" + e.toString()); System.err.println(e); //e.printStackTrace(); return false; } }
From source file:com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithms.java
private static VehicleRoutingAlgorithm readAndCreateAlgorithm(final VehicleRoutingProblem vrp, XMLConfiguration config, int nuOfThreads, final SolutionCostCalculator solutionCostCalculator, final StateManager stateManager, ConstraintManager constraintManager, boolean addDefaultCostCalculators, boolean addCoreConstraints) { // map to store constructed modules TypedMap definedClasses = new TypedMap(); // algorithm listeners Set<PrioritizedVRAListener> algorithmListeners = new HashSet<PrioritizedVRAListener>(); // insertion listeners List<InsertionListener> insertionListeners = new ArrayList<InsertionListener>(); //threading//from w w w .j a v a 2s . c o m final ExecutorService executorService; if (nuOfThreads > 0) { log.debug("setup executor-service with " + nuOfThreads + " threads"); executorService = Executors.newFixedThreadPool(nuOfThreads); algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, new AlgorithmEndsListener() { @Override public void informAlgorithmEnds(VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) { log.debug("shutdown executor-service"); executorService.shutdown(); } })); Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread arg0, Throwable arg1) { System.err.println(arg1.toString()); } }); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { if (!executorService.isShutdown()) { System.err.println("shutdowHook shuts down executorService"); executorService.shutdown(); } } }); } else executorService = null; //create fleetmanager final VehicleFleetManager vehicleFleetManager = createFleetManager(vrp); String switchString = config.getString("construction.insertion.allowVehicleSwitch"); final boolean switchAllowed; if (switchString != null) { switchAllowed = Boolean.parseBoolean(switchString); } else switchAllowed = true; ActivityTimeTracker.ActivityPolicy activityPolicy; if (stateManager.timeWindowUpdateIsActivated()) { UpdateVehicleDependentPracticalTimeWindows timeWindowUpdater = new UpdateVehicleDependentPracticalTimeWindows( stateManager, vrp.getTransportCosts(), vrp.getActivityCosts()); timeWindowUpdater .setVehiclesToUpdate(new UpdateVehicleDependentPracticalTimeWindows.VehiclesToUpdate() { Map<VehicleTypeKey, Vehicle> uniqueTypes = new HashMap<VehicleTypeKey, Vehicle>(); @Override public Collection<Vehicle> get(VehicleRoute vehicleRoute) { if (uniqueTypes.isEmpty()) { for (Vehicle v : vrp.getVehicles()) { if (!uniqueTypes.containsKey(v.getVehicleTypeIdentifier())) { uniqueTypes.put(v.getVehicleTypeIdentifier(), v); } } } Collection<Vehicle> vehicles = new ArrayList<Vehicle>(); vehicles.addAll(uniqueTypes.values()); return vehicles; } }); stateManager.addStateUpdater(timeWindowUpdater); activityPolicy = ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_TIME_WINDOW_OPENS; } else { activityPolicy = ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_ARRIVED; } stateManager.addStateUpdater( new UpdateActivityTimes(vrp.getTransportCosts(), activityPolicy, vrp.getActivityCosts())); stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager, activityPolicy)); final SolutionCostCalculator costCalculator; if (solutionCostCalculator == null) costCalculator = getDefaultCostCalculator(stateManager); else costCalculator = solutionCostCalculator; PrettyAlgorithmBuilder prettyAlgorithmBuilder = PrettyAlgorithmBuilder.newInstance(vrp, vehicleFleetManager, stateManager, constraintManager); if (addCoreConstraints) prettyAlgorithmBuilder.addCoreStateAndConstraintStuff(); //construct initial solution creator final InsertionStrategy initialInsertionStrategy = createInitialSolution(config, vrp, vehicleFleetManager, stateManager, algorithmListeners, definedClasses, executorService, nuOfThreads, costCalculator, constraintManager, addDefaultCostCalculators); if (initialInsertionStrategy != null) prettyAlgorithmBuilder.constructInitialSolutionWith(initialInsertionStrategy, costCalculator); //construct algorithm, i.e. search-strategies and its modules int solutionMemory = config.getInt("strategy.memory"); List<HierarchicalConfiguration> strategyConfigs = config .configurationsAt("strategy.searchStrategies.searchStrategy"); for (HierarchicalConfiguration strategyConfig : strategyConfigs) { String name = getName(strategyConfig); SolutionAcceptor acceptor = getAcceptor(strategyConfig, vrp, algorithmListeners, definedClasses, solutionMemory); SolutionSelector selector = getSelector(strategyConfig, vrp, algorithmListeners, definedClasses); SearchStrategy strategy = new SearchStrategy(name, selector, acceptor, costCalculator); strategy.setName(name); List<HierarchicalConfiguration> modulesConfig = strategyConfig.configurationsAt("modules.module"); for (HierarchicalConfiguration moduleConfig : modulesConfig) { SearchStrategyModule module = buildModule(moduleConfig, vrp, vehicleFleetManager, stateManager, algorithmListeners, definedClasses, executorService, nuOfThreads, constraintManager, addDefaultCostCalculators); strategy.addModule(module); } prettyAlgorithmBuilder.withStrategy(strategy, strategyConfig.getDouble("probability")); } //construct algorithm VehicleRoutingAlgorithm metaAlgorithm = prettyAlgorithmBuilder.build(); int maxIterations = getMaxIterations(config); if (maxIterations > -1) metaAlgorithm.setMaxIterations(maxIterations); //define prematureBreak PrematureAlgorithmTermination prematureAlgorithmTermination = getPrematureTermination(config, algorithmListeners); if (prematureAlgorithmTermination != null) metaAlgorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination); else { List<HierarchicalConfiguration> terminationCriteria = config .configurationsAt("terminationCriteria.termination"); for (HierarchicalConfiguration terminationConfig : terminationCriteria) { PrematureAlgorithmTermination termination = getTerminationCriterion(terminationConfig, algorithmListeners); if (termination != null) metaAlgorithm.addTerminationCriterion(termination); } } for (PrioritizedVRAListener l : algorithmListeners) { metaAlgorithm.getAlgorithmListeners().add(l); } return metaAlgorithm; }
From source file:com.vmware.photon.controller.api.client.resource.TasksApiTest.java
@Test public void testGetTaskAsync() throws Throwable { final Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_OK); TasksApi tasksApi = new TasksApi(this.restClient); tasksApi.getTaskAsync("foo", new FutureCallback<Task>() { @Override/* w ww. j a v a2 s . c o m*/ public void onSuccess(@Nullable Task task) { assertEquals(task, responseTask); } @Override public void onFailure(Throwable t) { fail(t.toString()); } }); }
From source file:com.vmware.photon.controller.api.client.resource.TasksRestApiTest.java
@Test public void testGetTaskAsync() throws Throwable { final Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_OK); TasksApi tasksApi = new TasksRestApi(this.restClient); tasksApi.getTaskAsync("foo", new FutureCallback<Task>() { @Override/*from ww w. j a v a 2 s.c om*/ public void onSuccess(@Nullable Task task) { assertEquals(task, responseTask); } @Override public void onFailure(Throwable t) { fail(t.toString()); } }); }
From source file:es.emergya.cliente.scheduler.jobs.UpdateAdminJob.java
@SuppressWarnings("unchecked") @Override// w w w . jav a 2 s .c om public void run() { try { for (final PluginListener o : (List<PluginListener>) Collections.synchronizedList(updatables)) try { if (!(o instanceof Option) || ((Option) o).needsUpdating()) { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { PluginEventHandler.fireChange(o); return null; } @Override protected void done() { super.done(); o.refresh(null); } }; sw.execute(); } } catch (Throwable t) { log.error("Error al actualizar " + o.toString() + " debido a " + t.toString()); } } catch (Throwable e) { log.fatal("Error al ejecutar la actualizacin de adminjob " + e.toString(), e); } }
From source file:com.vodafone360.people.service.transport.http.HttpConnectionThread.java
public static void logE(String tag, String message, Throwable error) { if (Settings.ENABLED_TRANSPORT_TRACE) { Thread t = Thread.currentThread(); if (null != error) { Log.e("(PROTOCOL)", "\n \n \n ################################################## \n" + tag + "[" + t.getName() + "]" + " : " + message, error); } else {//from ww w. j ava2 s . c o m Log.e("(PROTOCOL)", "\n \n \n ################################################## \n" + tag + "[" + t.getName() + "]" + " : " + message); } } if (null != error) { LogUtils.logE(message + " : " + error.toString()); } else { LogUtils.logE(message + " (Note: Settings.ENABLED_TRANSPORT_TRACE might give you more details!)"); } }
From source file:com.facebook.stetho.inspector.ChromeDevtoolsServer.java
@Override public void onError(SimpleSession session, Throwable ex) { LogRedirector.e(TAG, "onError: ex=" + ex.toString()); }