Java Code Examples for org.eclipse.core.runtime.CoreException#getCause()
The following examples show how to use
org.eclipse.core.runtime.CoreException#getCause() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaDocLocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Handles the exception thrown from JDT Core when the attached Javadoc * cannot be retrieved due to accessibility issues or location URL issue. This exception is not * logged but the exceptions occurred due to other reasons are logged. * * @param e the exception thrown when retrieving the Javadoc fails * @return the String message for why the Javadoc could not be retrieved * @since 3.9 */ public static String handleFailedJavadocFetch(CoreException e) { IStatus status= e.getStatus(); if (JavaCore.PLUGIN_ID.equals(status.getPlugin())) { Throwable cause= e.getCause(); int code= status.getCode(); // See bug 120559, bug 400060 and bug 400062 if (code == IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC_TIMEOUT || (code == IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC && (cause instanceof FileNotFoundException || cause instanceof SocketException || cause instanceof UnknownHostException || cause instanceof ProtocolException))) return CorextMessages.JavaDocLocations_error_gettingAttachedJavadoc; } JavaPlugin.log(e); return CorextMessages.JavaDocLocations_error_gettingJavadoc; }
Example 2
Source File: HybridProjectLaunchShortcut.java From thym with Eclipse Public License 1.0 | 6 votes |
private void launch(IProject project) { try { HybridProject hp = HybridProject.getHybridProject(project); if(!validateBuildToolsReady() || !shouldProceedWithLaunch(hp) || !RequirementsUtility.checkCordovaRequirements() ){ return; } ILaunchConfiguration launchConfig = findOrCreateLaunchConfiguration(project); ILaunchConfigurationWorkingCopy wc = launchConfig.getWorkingCopy(); updateLaunchConfiguration(wc); launchConfig = wc.doSave(); DebugUITools.launch(launchConfig, "run"); } catch (CoreException e) { if (e.getCause() instanceof IOException) { Status status = new Status(IStatus.ERROR, HybridUI.PLUGIN_ID, "Unable to complete the build for target plarform", e.getCause()); StatusManager.handle(status); }else{ StatusManager.handle(e); } } }
Example 3
Source File: InternalImpl.java From saros with GNU General Public License v2.0 | 6 votes |
@Override public void append(String projectName, String path, String content) throws RemoteException { log.trace( "appending content '" + content + "' to file '" + path + "' in project '" + projectName + "'"); path = path.replace('\\', '/'); IFile file = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getFile(path); try { file.appendContents(new ByteArrayInputStream(content.getBytes()), true, false, null); } catch (CoreException e) { log.error(e.getMessage(), e); throw new RemoteException(e.getMessage(), e.getCause()); } }
Example 4
Source File: InternalImpl.java From saros with GNU General Public License v2.0 | 6 votes |
@Override public void createFolder(String projectName, String path) throws RemoteException { path = path.replace('\\', '/'); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); try { String segments[] = path.split("/"); IFolder folder = project.getFolder(segments[0]); log.trace(Arrays.asList(segments)); if (!folder.exists()) folder.create(true, true, null); if (segments.length <= 1) return; for (int i = 1; i < segments.length; i++) { folder = folder.getFolder(segments[i]); if (!folder.exists()) folder.create(true, true, null); } } catch (CoreException e) { log.error(e.getMessage(), e); throw new RemoteException(e.getMessage(), e.getCause()); } }
Example 5
Source File: TestUtil.java From netbeans with Apache License 2.0 | 5 votes |
public static void handleException(Exception exception) throws Throwable { if (exception instanceof CoreException) { CoreException e = (CoreException) exception; IStatus status = e.getStatus(); if (status instanceof RepositoryStatus) { RepositoryStatus rs = (RepositoryStatus) status; String html = rs.getHtmlMessage(); if(html != null && !html.trim().equals("")) { // HtmlBrowser.URLDisplayer displayer = HtmlBrowser.URLDisplayer.getDefault (); // if (displayer != null) { // displayer.showURL (url); // } else { // //LOG.info("No URLDisplayer found."); // } final HtmlPanel p = new HtmlPanel(); p.setHtml(html); BugzillaUtil.show(p, "html", "ok"); } throw new Exception(rs.getHtmlMessage()); } if (e.getStatus().getException() != null) { throw e.getStatus().getException(); } if (e.getCause() != null) { throw e.getCause(); } throw e; } exception.printStackTrace(); throw exception; }
Example 6
Source File: InternalImpl.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public void createFile(String projectName, String path, int size, boolean compressAble) throws RemoteException { log.trace( "creating file in project '" + projectName + "', path '" + path + "' size: " + size + ", compressAble=" + compressAble); path = path.replace('\\', '/'); int idx = path.lastIndexOf('/'); if (idx != -1) createFolder(projectName, path.substring(0, idx)); IFile file = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getFile(path); try { file.create(new GeneratingInputStream(size, compressAble), true, null); } catch (CoreException e) { log.error(e.getMessage(), e); throw new RemoteException(e.getMessage(), e.getCause()); } }
Example 7
Source File: InternalImpl.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public void createProject(String projectName) throws RemoteException { log.trace("creating project: " + projectName); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); try { project.create(null); project.open(null); } catch (CoreException e) { log.error("unable to create project '" + projectName + "' : " + e.getMessage(), e); throw new RemoteException(e.getMessage(), e.getCause()); } }
Example 8
Source File: InternalImpl.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public void changeProjectEncoding(String projectName, String charset) throws RemoteException { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); try { project.setDefaultCharset(charset, null); } catch (CoreException e) { log.error(e.getMessage(), e); throw new RemoteException(e.getMessage(), e.getCause()); } }
Example 9
Source File: InternalImpl.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public void changeFileEncoding(String projectName, String path, String charset) throws RemoteException { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); IFile file = project.getFile(path); try { file.setCharset(charset, null); } catch (CoreException e) { log.error(e.getMessage(), e); throw new RemoteException(e.getMessage(), e.getCause()); } }
Example 10
Source File: EclipseUtils.java From goclipse with Eclipse Public License 1.0 | 4 votes |
public static CommonException createCommonException(CoreException ce) { return new CommonException(ce.getMessage(), ce.getCause()); }
Example 11
Source File: InternalImpl.java From saros with GNU General Public License v2.0 | 3 votes |
@Override public void createJavaProject(String projectName) throws RemoteException { log.trace("creating java project: " + projectName); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); try { project.create(null); project.open(null); IProjectDescription description = project.getDescription(); description.setNatureIds(new String[] {JavaCore.NATURE_ID}); project.setDescription(description, null); IJavaProject javaProject = JavaCore.create(project); Set<IClasspathEntry> entries = new HashSet<IClasspathEntry>(); entries.add(JavaCore.newSourceEntry(javaProject.getPath().append("src"), new IPath[0])); IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall(); LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall); for (LibraryLocation element : locations) { entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null)); } javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null); } catch (CoreException e) { log.error("unable to create java project '" + projectName + "' :" + e.getMessage(), e); throw new RemoteException(e.getMessage(), e.getCause()); } }