List of usage examples for java.lang Throwable getLocalizedMessage
public String getLocalizedMessage()
From source file:org.deegree.maven.ithelper.ServiceIntegrationTestHelper.java
public void testCapabilities(String service) throws MojoFailureException { String address = createBaseURL() + "services/" + service.toLowerCase() + "?request=GetCapabilities&service=" + service;/* w w w .j a va2s .c om*/ try { log.info("Reading capabilities from " + address); String input = IOUtils.toString(new URL(address).openStream(), "UTF-8"); XMLInputFactory fac = XMLInputFactory.newInstance(); XMLStreamReader in = fac.createXMLStreamReader(new StringReader(input)); in.next(); if (in.getLocalName().toLowerCase().contains("exception")) { log.error("Actual response was:"); log.error(input); throw new MojoFailureException("Retrieving capabilities from " + address + " failed."); } } catch (Throwable e) { log.debug("Failed to retrieve capabilities.", e); throw new MojoFailureException( "Retrieving capabilities for " + service + " failed: " + e.getLocalizedMessage(), e); } }
From source file:com.example.parkhere.provider.AddSeekerRoleFragment.java
public void createSeekerProfileProcess(SeekerPayment seekerPayment, BillingAddress billingAddress, Vehicle vehicle) {/* w w w .j a v a 2s . co m*/ final ProgressDialog progressDialog = new ProgressDialog(rootView.getContext(), R.style.AppTheme_Dark_Dialog); progressDialog.setIndeterminate(true); progressDialog.setMessage("Adding Seeker Role..."); progressDialog.show(); Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.BASE_URL) .addConverterFactory(GsonConverterFactory.create()).build(); RequestInterface requestInterface = retrofit.create(RequestInterface.class); ServerRequest request = new ServerRequest(); request.setOperation(Constants.ADD_SEEKER_ROLE_OPERATION); request.setUser(user); request.setSeekerPayment(seekerPayment); request.setBillingAddress(billingAddress); request.setVehicle(vehicle); Call<ServerResponse> response = requestInterface.operation(request); response.enqueue(new Callback<ServerResponse>() { @Override public void onResponse(Call<ServerResponse> call, retrofit2.Response<ServerResponse> response) { ServerResponse resp = response.body(); if (resp.getResult().equals(Constants.SUCCESS)) { goToSeekerUserhomeScreen(); } progressDialog.dismiss(); Snackbar.make(create_sprof_scrollview, resp.getMessage(), Snackbar.LENGTH_LONG).show(); } @Override public void onFailure(Call<ServerResponse> call, Throwable t) { progressDialog.dismiss(); Snackbar.make(create_sprof_scrollview, t.getLocalizedMessage(), Snackbar.LENGTH_LONG).show(); } }); }
From source file:com.kii.sample.hellothingif.CommandFragment.java
@OnClick(R.id.buttonSend) void onSendCommand() { ProgressDialogFragment.show(getActivity(), getFragmentManager(), R.string.progress_send_command); mCommandResult.setText(""); List<Action> actions = new ArrayList<>(); TurnPower action1 = new TurnPower(); action1.power = mCheckBoxPowerOn.isChecked(); actions.add(action1);//from w w w.j av a2 s . c om if (action1.power) { SetBrightness action2 = new SetBrightness(); action2.brightness = mSeekBarBrightness.getProgress(); actions.add(action2); } PromiseAPIWrapper api = new PromiseAPIWrapper(mAdm, mApi); mAdm.when(api.postNewCommand(HelloThingIF.SCHEMA_NAME, HelloThingIF.SCHEMA_VERSION, actions)) .then(new DoneCallback<Command>() { @Override public void onDone(Command command) { ProgressDialogFragment.close(getFragmentManager()); String commandID = command.getCommandID(); showToast("The command has been sent: " + commandID); } }).fail(new FailCallback<Throwable>() { @Override public void onFail(final Throwable tr) { ProgressDialogFragment.close(getFragmentManager()); showToast("Failed to send the command: " + tr.getLocalizedMessage()); } }); }
From source file:org.ebayopensource.turmeric.eclipse.utils.ui.UIUtil.java
/** * Gets the detailed exception stack trace. * * @param exception the exception//from www . j a va2 s . com * @return the detailed exception stack trace */ public static IStatus getDetailedExceptionStackTrace(final Throwable exception) { IStatus status = null; if (exception instanceof CoreException) { status = ((CoreException) exception).getStatus(); } else { final String reason; if (exception.getCause() != null) { reason = exception.getCause().getLocalizedMessage(); } else { reason = exception.getLocalizedMessage(); } MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, 1, StringUtils.defaultString(reason), null); status = multiStatus; String stackTrace = ExceptionUtils.getStackTrace(exception); BufferedReader br = new BufferedReader(new StringReader(stackTrace)); String line = null; try { while ((line = br.readLine()) != null) { multiStatus.merge(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 1, line, null)); } } catch (IOException ioex) { ioex.printStackTrace(); } finally { IOUtils.closeQuietly(br); } } return status; }
From source file:com.idevity.card.read.ReadMain.java
@TargetApi(19) @Override/*from ww w.ja va2s.c o m*/ public void onDestroy() { if (debug) { Log.d(TAG, "onDestroy()"); } /* * Platform version specific handling: KitKat */ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { if (adapter != null) { if (debug) { Log.d(TAG, "disabling listener"); } try { adapter.disableReaderMode(this); } catch (Throwable e) { Log.e(TAG, "Problem disabling reader mode: " + e.getLocalizedMessage()); } } } super.onDestroy(); }
From source file:com.idevity.card.read.ReadMain.java
@TargetApi(19) @Override/*ww w . j a va 2 s .c om*/ public void onPause() { if (debug) { Log.d(TAG, "onPause()"); } /* * Platform version specific handling: KitKat */ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { if (adapter != null) { if (debug) { Log.d(TAG, "disabling listener"); } try { adapter.disableReaderMode(this); } catch (Throwable e) { Log.e(TAG, "Problem disabling reader mode: " + e.getLocalizedMessage()); } } } super.onPause(); }
From source file:de.iteratec.iteraplan.presentation.dialog.Search.SearchController.java
@ExceptionHandler(IteraplanBusinessException.class) public ModelAndView handleIteraplanBusinessException(Throwable ex, HttpServletRequest req, HttpServletResponse resp) {//from w w w.ja v a2s. com ModelAndView mav = new ModelAndView("search/search"); this.init(mav.getModelMap(), req.getSession(), req); mav.getModelMap().addAttribute(Constants.JSP_ATTRIBUTE_EXCEPTION_MESSAGE, ex.getLocalizedMessage()); IteraplanProblemReport.createFromController(ex, req); return mav; }
From source file:org.bedework.eventreg.bus.CSVOutputter.java
@Override public String next() { if (!regit.hasNext()) { return null; }/* w ww .ja v a2s.c o m*/ /* ><c:forEach var="reg" items="${regs}" varStatus="loopStatus"><%-- </c:forEach> */ final List flds = new ArrayList(); final Registration reg = regit.next(); final StringBuilder out = new StringBuilder(); try { final CSVPrinter csv = new CSVPrinter(out, CSVFormat.EXCEL); flds.add(reg.getEvSummary()); flds.add(reg.getEvDate()); flds.add(reg.getEvTime()); flds.add(reg.getEvLocation()); flds.add(reg.getRegistrationId()); flds.add(reg.getAuthid()); flds.add(reg.getTicketsRequested()); flds.add(reg.getNumTickets()); flds.add(reg.getType()); flds.add(reg.getComment()); flds.add(reg.getCreated()); flds.add(reg.getLastmod()); if (form == null) { csv.printRecord(flds.toArray()); csv.flush(); csv.close(); return out.toString(); } final FormFields ff = new FormFields(form.getFields()); try { final Map vals = reg.restoreFormValues(); for (final FieldDef fd : ff) { final Object val = vals.get(fd.getName()); if (val == null) { flds.add(""); } else { flds.add(val); } } } catch (final Throwable t) { out.append("Exception restoring form values"); } csv.printRecord(flds.toArray()); csv.flush(); csv.close(); } catch (final Throwable t) { return "Exception " + t.getLocalizedMessage(); } return out.toString(); }
From source file:org.geoserver.taskmanager.web.BatchPage.java
protected AjaxSubmitLink saveButton() { return new AjaxSubmitLink("save") { private static final long serialVersionUID = 3735176778941168701L; @Override/*from ww w. j a va 2s .c o m*/ public void onSubmit(AjaxRequestTarget target, Form<?> form) { try { Configuration config = batchModel.getObject().getConfiguration(); batchModel.setObject(TaskManagerBeans.get().getDataUtil() .saveScheduleAndRemove(batchModel.getObject(), removedElements)); //update the old config (still used on configuration page) if (config != null) { config.getBatches().put(batchModel.getObject().getName(), batchModel.getObject()); } doReturn(); } catch (ConstraintViolationException e) { form.error(new ParamResourceModel("duplicate", getPage()).getString()); addFeedbackPanels(target); } catch (Exception e) { LOGGER.log(Level.WARNING, e.getMessage(), e); Throwable rootCause = ExceptionUtils.getRootCause(e); form.error(rootCause == null ? e.getLocalizedMessage() : rootCause.getLocalizedMessage()); addFeedbackPanels(target); } } protected void onError(AjaxRequestTarget target, Form<?> form) { addFeedbackPanels(target); } }; }
From source file:org.deegree.commons.config.AbstractResourceManager.java
/** * Processes the given resource configuration file and returns the resulting resource state. * <p>//from www .jav a2 s .c om * This method does not update the resource / state maps. * </p> * * @param configFile * configuration file, must not be <code>null</code> * @return resource state, can be null if resource manager does not want to handle the config * @throws IOException * if the resource filename is invalid / could not be processed */ protected ResourceState<T> processResourceConfig(File configFile) throws IOException { LOG.debug("Processing file '{}'", configFile); ResourceState<T> state = null; String dirName = dir.getCanonicalPath(); String fileName = configFile.getCanonicalPath().substring(dirName.length()); ResourceProvider provider = getProvider(configFile.toURI().toURL()); if (fileName.startsWith(File.separator)) { fileName = fileName.substring(1); } if (fileName.endsWith(".xml")) { // 4 is the length of ".xml" String id = fileName.substring(0, fileName.length() - 4); LOG.info("Setting up {} '{}' from file '{}'...", new Object[] { name, id, fileName }); if (provider != null) { try { T resource = create(id, configFile.toURI().toURL()); state = new ResourceState<T>(id, configFile, provider, created, resource, null); resource.init(workspace); state = new ResourceState<T>(id, configFile, provider, init_ok, resource, null); add(resource); } catch (ResourceInitException e) { LOG.error("Could not create resource {}: {}", name, e.getLocalizedMessage()); if (e.getCause() != null) { LOG.error("Cause was: {}", e.getCause().getLocalizedMessage()); } LOG.trace("Stack trace:", e); state = new ResourceState<T>(id, configFile, provider, init_error, null, e); } catch (Throwable t) { LOG.error("Could not create resource {}: {}", name, t.getLocalizedMessage()); if (t.getCause() != null) { LOG.error("Cause was: {}", t.getCause().getLocalizedMessage()); } LOG.trace("Stack trace:", t); state = new ResourceState<T>(id, configFile, provider, init_error, null, new ResourceInitException(t.getMessage(), t)); } } else { String msg = "No suitable resource provider available."; ResourceInitException e = new ResourceInitException(msg); state = new ResourceState<T>(id, configFile, provider, init_error, null, e); } } else { // 7 is the length of ".ignore" String id = fileName.substring(0, fileName.length() - 7); state = new ResourceState<T>(id, configFile, provider, deactivated, null, null); } return state; }