Java Code Examples for org.eclipse.emf.common.util.WrappedException#getCause()
The following examples show how to use
org.eclipse.emf.common.util.WrappedException#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: JavaClassPathResourceForIEditorInputFactoryTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test(expected=CoreException.class) public void testBug463258_03b() throws Throwable { IJavaProject project = createJavaProject("foo"); IFile file = project.getProject().getFile("foo.jar"); file.create(jarInputStream(new TextFile("foo/bar.testlanguage", "//empty")), true, monitor()); IPackageFragmentRoot root = JarPackageFragmentRootTestUtil.getJarPackageFragmentRoot(file, (JavaProject) project); IPackageFragment foo = root.getPackageFragment("foo"); JarEntryFile fileInJar = new JarEntryFile("bar.testlanguage"); fileInJar.setParent(foo); File jarFile = file.getLocation().toFile(); assertTrue("exists", jarFile.exists()); assertTrue("delete", jarFile.delete()); XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar); try { factory.createResource(editorInput); } catch(WrappedException e) { throw e.getCause(); } }
Example 2
Source File: JavaClassPathResourceForIEditorInputFactoryTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test(expected=CoreException.class) public void testBug463258_03c() throws Throwable { IJavaProject project = createJavaProject("foo"); IFile file = project.getProject().getFile("foo.jar"); file.create(jarInputStream(new TextFile("foo/bar.testlanguage", "//empty")), true, monitor()); addJarToClasspath(project, file); IPackageFragmentRoot root = JarPackageFragmentRootTestUtil.getJarPackageFragmentRoot(file, (JavaProject) project); IPackageFragment foo = root.getPackageFragment("foo"); JarEntryFile fileInJar = new JarEntryFile("bar.testlanguage"); fileInJar.setParent(foo); File jarFile = file.getLocation().toFile(); assertTrue("exists", jarFile.exists()); assertTrue("delete", jarFile.delete()); // simulate an automated refresh file.refreshLocal(IResource.DEPTH_ONE, null); XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar); try { factory.createResource(editorInput); } catch(WrappedException e) { throw e.getCause(); } }
Example 3
Source File: JavaClassPathResourceForIEditorInputFactoryTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test(expected=CoreException.class) public void testBug463258_04() throws Throwable { IFolder externalFolder = createExternalFolder("externalFolder"); IJavaProject project = createJavaProject("foo"); addExternalFolderToClasspath(project, externalFolder); IPackageFragmentRoot root = project.getPackageFragmentRoot(externalFolder); IPackageFragment foo = root.getPackageFragment("foo"); NonJavaResource fileInFolder = new NonJavaResource(foo, externalFolder.getFile("foo/doesNotExist.testlanguage")); externalFolder.delete(true, null); XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInFolder); try { factory.createResource(editorInput); } catch(WrappedException e) { throw e.getCause(); } }
Example 4
Source File: JavaClassPathResourceForIEditorInputFactoryTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test(expected=CoreException.class) public void testBug463258_05() throws Throwable { IJavaProject project = createJavaProject("foo"); IPackageFragmentRoot root = project.getPackageFragmentRoot("does/not/exist.jar"); IPackageFragment foo = root.getPackageFragment("foo"); final JarEntryFile fileInJar = new JarEntryFile("bar.testlanguage"); fileInJar.setParent(foo); XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar); try { factory.createResource(editorInput); } catch(WrappedException e) { throw e.getCause(); } }
Example 5
Source File: JdtTypeProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
private JvmType findObjectTypeInJavaProject(/* @NonNull */ String signature, /* @NonNull */ URI resourceURI, boolean traverseNestedTypes) throws JavaModelException { IType type = findObjectTypeInJavaProject(resourceURI); if (type != null) { try { return createResourceAndFindType(resourceURI, type, signature, traverseNestedTypes); } catch (IOException ioe) { return null; } catch (WrappedException wrapped) { if (wrapped.getCause() instanceof IOException) { return null; } throw wrapped; } } return null; }
Example 6
Source File: BuildScopeAwareParallelLoader.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public LoadResult next() { URI uri = queue.poll(); try { Resource resource = parent.getResource(uri, true); return new LoadResult(resource, uri); } catch (WrappedException e) { throw new LoadOperationException(uri, (Exception) e.getCause()); } }
Example 7
Source File: FileResourceHandler.java From xtext-web with Eclipse Public License 2.0 | 5 votes |
@Override public void put(IXtextWebDocument document, IServiceContext serviceContext) throws IOException { try { URI uri = resourceBaseProvider.getFileURI(document.getResourceId()); try (OutputStreamWriter writer = new OutputStreamWriter( document.getResource().getResourceSet().getURIConverter().createOutputStream(uri), encodingProvider.getEncoding(uri))) { writer.write(document.getText()); } catch (WrappedException exception) { throw exception.getCause(); } } catch (Throwable e) { throw Exceptions.sneakyThrow(e); } }
Example 8
Source File: SerialResourceLoader.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public LoadOperation create(final ResourceSet parent, IProject project) { final Queue<URI> queue = Lists.newLinkedList(); return new CheckedLoadOperation(new LoadOperation() { @Override public LoadResult next() { URI uri = queue.poll(); try { Resource resource = parent.getResource(uri, true); return new LoadResult(resource, uri); } catch(WrappedException e) { throw new LoadOperationException(uri, (Exception) e.getCause() ); } } @Override public boolean hasNext() { return !queue.isEmpty(); } @Override public Collection<URI> cancel() { return queue; } @Override public void load(Collection<URI> uris) { queue.addAll(getSorter().sort(uris)); } }); }
Example 9
Source File: EncodingTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testUtfBytesWithIsoOptions() throws Exception { XtextResource resource = createXtextResource(); try { resource.load(new ByteArrayInputStream(utfBytes), isoOptions); assertFalse(resource.getErrors().toString(), resource.getErrors().isEmpty()); } catch (WrappedException e) { if (e.getCause() instanceof CharConversionException) { // ok } else { throw e; } } resource.reparse(model); assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty()); }
Example 10
Source File: EncodingTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testIsoBytesWithUtfOptions() throws Exception { XtextResource resource = createXtextResource(); try { resource.load(new ByteArrayInputStream(isoBytes), utfOptions); assertFalse(resource.getErrors().toString(), resource.getErrors().isEmpty()); } catch(WrappedException e) { if (e.getCause() instanceof CharConversionException) { // ok } else { throw e; } } resource.reparse(model); assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty()); }
Example 11
Source File: OutdatedStateManagerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testChecked() { try { outdatedStateManager.exec((r) -> { throw new IOException(); }, resource); fail("Exception Expected"); } catch (WrappedException e) { Throwable cause = e.getCause(); assertTrue("wrong cause", cause instanceof IOException); } }
Example 12
Source File: DoUpdateImplementation.java From n4js with Eclipse Public License 1.0 | 4 votes |
private int doUpdateCluster() { int clusterIndex = 0; final List<Delta> changedDeltas = Lists.newArrayList(); while (!queue.isEmpty()) { checkCancelled(); if (!continueProcessing(clusterIndex)) { break; } URI changedURI = null; Resource resource = null; Delta newDelta = null; try { // Load the resource and create a new resource description LoadResult loadResult = loadOperation.next(); changedURI = loadResult.getUri(); progress.subTask("Linking " + changedURI.lastSegment() + " and dependencies"); URI actualResourceURI = loadResult.getResource().getURI(); resource = state.addResource(loadResult.getResource(), resourceSet); reportProgress(); if (!removeFromQueue(changedURI)) { break; } buildLogger.log("Linking " + changedURI); newDelta = resolveLinks(actualResourceURI, resource); } catch (final WrappedException ex) { if (ex instanceof LoadOperationException) { changedURI = ((LoadOperationException) ex).getUri(); } Throwable cause = ex.getCause(); boolean wasResourceNotFound = false; if (cause instanceof CoreException) { if (IResourceStatus.RESOURCE_NOT_FOUND == ((CoreException) cause).getStatus() .getCode()) { wasResourceNotFound = true; } } if (changedURI == null) { LOGGER.error("Error loading resource", ex); //$NON-NLS-1$ } else { if (!removeFromQueue(changedURI)) { break; } if (!wasResourceNotFound) LOGGER.error("Error loading resource from: " + changedURI.toString(), ex); //$NON-NLS-1$ if (resource != null) { resourceSet.getResources().remove(resource); } newDelta = createRemoveDelta(changedURI); } } if (newDelta != null) { clusterIndex++; if (processNewDelta(newDelta)) { changedDeltas.add(newDelta); } } } loadOperation.cancel(); queueAffectedResources(changedDeltas); return clusterIndex; }