/** * Cancel the client selection. * * @return boolean */ public boolean performCancel() { final List<WizardFragment> list = getAllWizardFragments(); IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { Iterator<WizardFragment> iterator = list.iterator(); while (iterator.hasNext()) executeTask((WizardFragment) iterator.next(), CANCEL, monitor); } catch (CoreException ce) { throw new InvocationTargetException(ce); } } }; Throwable t = null; try { if (getContainer() != null) getContainer().run(true, true, runnable); else runnable.run(new NullProgressMonitor()); return true; } catch (InvocationTargetException te) { t = te.getCause(); } catch (Exception e) { t = e; } PHPUiPlugin.log( new Status( IStatus.ERROR, PHPUiPlugin.ID, 0, "Error cancelling task wizard", t)); // $NON-NLS-1$ if (t instanceof CoreException) { openError(t.getLocalizedMessage(), ((CoreException) t).getStatus()); } else openError(t.getLocalizedMessage()); return false; }
public static String toMessage(Throwable t) { String message; if (t.getLocalizedMessage() == null) { message = "No description was provided"; } else if (t.getLocalizedMessage().toLowerCase().indexOf("side location conflict") > -1) { message = t.getLocalizedMessage() + " -- Check for invalid geometries."; } else { message = t.getLocalizedMessage(); } return message + " (" + StringUtil.toFriendlyName(t.getClass().getName()) + ")"; }
public Processor next() { try { return (Processor) (iterator.next()); } catch (Throwable t) { if ("ServiceConfigurationError".equals(t.getClass().getSimpleName())) { log.error("proc.bad.config.file", t.getLocalizedMessage()); } else { log.error("proc.processor.constructor.error", t.getLocalizedMessage()); } throw new Abort(t); } }
public void doError( HttpServletRequest request, HttpServletResponse response, String s, String message, Throwable e) throws java.io.IOException { if (e != null) { M_log.error(e.getLocalizedMessage(), e); } M_log.info(rb.getString(s) + ": " + message); String return_url = request.getParameter(BasicLTIConstants.LAUNCH_PRESENTATION_RETURN_URL); if (return_url != null && return_url.length() > 1) { if (return_url.indexOf('?') > 1) { return_url += "<i_msg=" + URLEncoder.encode(rb.getString(s), "UTF-8"); } else { return_url += "?lti_msg=" + URLEncoder.encode(rb.getString(s), "UTF-8"); } // Avoid Response Splitting return_url = return_url.replaceAll("[\r\n]", ""); response.sendRedirect(return_url); return; } PrintWriter out = response.getWriter(); out.println(rb.getString(s)); }
public boolean hasNext() { try { return iterator.hasNext(); } catch (Throwable t) { if ("ServiceConfigurationError".equals(t.getClass().getSimpleName())) { log.error("proc.bad.config.file", t.getLocalizedMessage()); } throw new Abort(t); } }
/** Runs the merge protocol as a leader */ public void run() { // 1. Generate merge_id MergeId new_merge_id = MergeId.create(gms.local_addr); Collection<Address> coordsCopy = null; try { boolean success = setMergeId(null, new_merge_id); if (!success) { log.warn("failed to set my own merge_id (" + merge_id + ") to " + new_merge_id); return; } coordsCopy = new ArrayList<Address>(coords.keySet()); /* 2. Fetch the current Views/Digests from all subgroup coordinators */ success = getMergeDataFromSubgroupCoordinators(coords, new_merge_id, gms.merge_timeout); if (!success) throw new Exception( "merge leader did not get data from all partition coordinators " + coords.keySet()); /* 3. Remove rejected MergeData elements from merge_rsp and coords (so we'll send the new view * only to members who accepted the merge request) */ removeRejectedMergeRequests(coords.keySet()); if (merge_rsps.size() == 0) throw new Exception("did not get any merge responses from partition coordinators"); if (!coords .keySet() .contains( gms.local_addr)) // another member might have invoked a merge req on us before we // got there... throw new Exception("merge leader rejected merge request"); /* 4. Combine all views and digests into 1 View/1 Digest */ Vector<MergeData> merge_data = new Vector<MergeData>(merge_rsps.getResults().values()); MergeData combined_merge_data = consolidateMergeData(merge_data); if (combined_merge_data == null) throw new Exception("could not consolidate merge"); /* 4. Send the new View/Digest to all coordinators (including myself). On reception, they will install the digest and view in all of their subgroup members */ sendMergeView(coords.keySet(), combined_merge_data, new_merge_id); } catch (Throwable ex) { if (log.isWarnEnabled()) log.warn(gms.local_addr + ": " + ex.getLocalizedMessage() + ", merge is cancelled"); sendMergeCancelledMessage(coordsCopy, new_merge_id); } finally { gms.getViewHandler().resume(new_merge_id); stopMergeCanceller(); // this is probably not necessary /*5. if flush is in stack stop the flush for entire cluster [JGRP-700] - FLUSH: flushing should span merge */ gms.stopFlush(); if (log.isDebugEnabled()) log.debug(gms.local_addr + ": merge leader completed merge task"); thread = null; } }
@NonNls private static String message(Throwable e) { String message = e.getMessage(); if (message != null) return message; message = e.getLocalizedMessage(); if (message != null) return message; message = e.toString(); Throwable cause = e.getCause(); if (cause != null) { String causeMessage = message(cause); return message + " (cause: " + causeMessage + ")"; } return message; }
/** * Shows an error and a short description. * * @param ex the exception */ static void showError(Throwable ex, String title, String message) { try { if (title == null) title = "Error in SIP contactlist storage"; if (message == null) message = title + "\n" + ex.getClass().getName() + ": " + ex.getLocalizedMessage(); if (SipActivator.getUIService() != null) SipActivator.getUIService() .getPopupDialog() .showMessagePopupDialog(message, title, PopupDialog.ERROR_MESSAGE); } catch (Throwable t) { logger.error("Error for error dialog", t); } }
/** * {@link RemoteUtil#unwrap(Throwable) unwraps} given exception if possible and builds error * message for it. * * @param e exception to process * @return error message for the given exception */ @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "IOResourceOpenedButNotSafelyClosed"}) @NotNull public static String buildErrorMessage(@NotNull Throwable e) { Throwable unwrapped = RemoteUtil.unwrap(e); String reason = unwrapped.getLocalizedMessage(); if (!StringUtil.isEmpty(reason)) { return reason; } else if (unwrapped.getClass() == ExternalSystemException.class) { return String.format( "exception during working with external system: %s", ((ExternalSystemException) unwrapped).getOriginalReason()); } else { StringWriter writer = new StringWriter(); unwrapped.printStackTrace(new PrintWriter(writer)); return writer.toString(); } }
@Override public void onError(final Throwable th) { myInstance.setStatus(InstanceStatus.ERROR); if (th != null) { myInstance.updateErrors(TypedCloudErrorInfo.fromException(th)); LOG.warn( "An error occurred: " + th.getLocalizedMessage() + " during processing " + myInstance.getName()); } else { myInstance.updateErrors( new TypedCloudErrorInfo( "Unknown error during processing instance " + myInstance.getName())); LOG.warn("Unknown error during processing " + myInstance.getName()); } }
/** Invoked when a factory can't be loaded. Log a warning, but do not stop the process. */ private static void loadingFailure( final Class<?> category, final Throwable error, final boolean showStackTrace) { final String name = Classes.getShortName(category); final StringBuilder cause = new StringBuilder(Classes.getShortClassName(error)); final String message = error.getLocalizedMessage(); if (message != null) { cause.append(": "); cause.append(message); } final LogRecord record = Loggings.format(Level.WARNING, LoggingKeys.CANT_LOAD_SERVICE_$2, name, cause.toString()); if (showStackTrace) { record.setThrown(error); } record.setSourceClassName(FactoryRegistry.class.getName()); record.setSourceMethodName("scanForPlugins"); record.setLoggerName(LOGGER.getName()); LOGGER.log(record); }
public boolean performFinish() { if (currentFragment != null) currentFragment.exit(); final WizardFragment cFragment = currentFragment; status = Status.OK_STATUS; final List<WizardFragment> list = getAllWizardFragments(); IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { // enter & exit the remaining pages int index = list.indexOf(cFragment); while (index > 0 && index < list.size() - 1) { final WizardFragment fragment = (WizardFragment) list.get(++index); try { Display.getDefault() .syncExec( new Runnable() { public void run() { FragmentedWizardPage page = getFragmentData(fragment); if (page.getControl() == null && pageContainerHook != null) { page.createControl(pageContainerHook); } fragment.enter(); fragment.exit(); } }); } catch (Exception e) { PHPUiPlugin.log( new Status( IStatus.ERROR, PHPUiPlugin.ID, 0, "Could not enter/exit page", e)); //$NON-NLS-1$ } } if (useJob()) { class FinishWizardJob extends Job { public FinishWizardJob() { super(getJobTitle()); } public boolean belongsTo(Object family) { return "org.eclipse.wst.server.ui.family".equals(family); // $NON-NLS-1$ } public IStatus run(IProgressMonitor monitor2) { try { Iterator<WizardFragment> iterator = list.iterator(); while (iterator.hasNext()) executeTask(iterator.next(), FINISH, monitor2); } catch (CoreException ce) { Status status = new Status( IStatus.ERROR, PHPUiPlugin.ID, 0, ce.getLocalizedMessage(), null); PHPUiPlugin.log(status); return status; } return Status.OK_STATUS; } } FinishWizardJob job = new FinishWizardJob(); job.setUser(true); job.schedule(); } else { Iterator<WizardFragment> iterator = list.iterator(); while (iterator.hasNext()) try { WizardFragment fragment = (WizardFragment) iterator.next(); if (!executeTask(fragment, FINISH, monitor)) { status = new Status( IStatus.ERROR, PHPUiPlugin.ID, "Error during wizard page execution."); //$NON-NLS-1$ } } catch (CoreException e) { PHPUiPlugin.log(e); } } } }; Throwable t = null; try { if (getContainer() != null) getContainer().run(true, true, runnable); else runnable.run(new NullProgressMonitor()); if (status.getSeverity() != IStatus.OK) { return false; } return true; } catch (InvocationTargetException te) { PHPUiPlugin.log( new Status( IStatus.ERROR, PHPUiPlugin.ID, 0, "Error finishing task wizard", te)); // $NON-NLS-1$ t = te.getCause(); } catch (Exception e) { PHPUiPlugin.log( new Status( IStatus.ERROR, PHPUiPlugin.ID, 0, "Error finishing task wizard 2", e)); // $NON-NLS-1$ t = e; } if (t instanceof CoreException) { openError(t.getLocalizedMessage(), ((CoreException) t).getStatus()); } else if (t instanceof NullPointerException) openError(PHPUIMessages.FragmentedWizard_7); else openError(t.getLocalizedMessage()); return false; }